mirror of
https://github.com/hcengineering/platform.git
synced 2026-09-22 09:35:00 +02:00
27 lines
870 B
TypeScript
27 lines
870 B
TypeScript
//
|
|
// Copyright @ 2024 Hardcore Engineering Inc.
|
|
//
|
|
|
|
import type { Question } from '@hcengineering/questions'
|
|
import { type QuerySelector, SortingOrder } from '@hcengineering/core'
|
|
import { getClient } from '@hcengineering/presentation'
|
|
import questions from '../plugin'
|
|
|
|
export async function findPreviousQuestion (object: Question<unknown>): Promise<Question<unknown> | undefined> {
|
|
return await getClient().findOne<Question<unknown>>(
|
|
questions.class.Question,
|
|
{
|
|
attachedTo: object.attachedTo,
|
|
attachedToClass: object.attachedToClass,
|
|
collection: object.collection,
|
|
// TODO: Ugly typings hack, because QuerySelector currently does not let use '$lt` on strings
|
|
rank: { $lt: object.rank } as unknown as QuerySelector<Question<unknown>['rank']>
|
|
},
|
|
{
|
|
sort: {
|
|
rank: SortingOrder.Descending
|
|
}
|
|
}
|
|
)
|
|
}
|