import { GroupIDStr } from "../../../Datastore" ; import { BaseDocAnnotation } from "./BaseDocAnnotation" ; import { Clause , Collections , OrderByClause } from "../Collections" ; import { IDStr } from "polar-shared/src/util/Strings" ; import { Arrays } from "polar-shared/src/util/Arrays" ; export class GroupDocAnnotations { public static readonly COLLECTION = 'group_doc_annotation' ; public static async list ( groupID ) { const orderBy = [ [ 'lastUpdated' , 'desc' ] ] ; const limit = 50 ; const clauses = [ [ 'groupID' , '==' , groupID ] ] ; return await Collections . list ( this . COLLECTION , clauses , { limit , orderBy } ) ; } public static async get ( groupID , id ) { const limit = 1 ; const clauses = [ [ 'groupID' , '==' , groupID ] , [ 'id' , '==' , id ] ] ; const results = await Collections . list ( this . COLLECTION , clauses , { limit } ) ; return Arrays . first ( results ) ; } } export interface GroupDocAnnotation extends BaseDocAnnotation { readonly groupID : GroupIDStr ; }