(
domainId: string, content: Content, owner: number,
docType: number, docId: DocID = null,
parentType: number | null = null, parentId: DocID = null,
args: any = {},
)
| 64 | args?: Partial<DocType[T]>, |
| 65 | ): Promise<ObjectId>; |
| 66 | export async function add( |
| 67 | domainId: string, content: Content, owner: number, |
| 68 | docType: number, docId: DocID = null, |
| 69 | parentType: number | null = null, parentId: DocID = null, |
| 70 | args: any = {}, |
| 71 | ) { |
| 72 | const _id = new ObjectId(); |
| 73 | const doc: any = { |
| 74 | _id, |
| 75 | content, |
| 76 | owner, |
| 77 | domainId, |
| 78 | docType, |
| 79 | docId: docId || _id, |
| 80 | ...args, |
| 81 | }; |
| 82 | if (parentType || parentId) { |
| 83 | assert(parentType && parentId); |
| 84 | doc.parentType = parentType; |
| 85 | doc.parentId = parentId; |
| 86 | } |
| 87 | await bus.parallel('document/add', doc); |
| 88 | const res = await coll.insertOne(doc); |
| 89 | return docId || res.insertedId; |
| 90 | } |
| 91 | |
| 92 | export async function get<K extends keyof DocType>(domainId: string, docType: K, docId: DocType[K]['docId'], projection?: Projection<DocType[K]>) { |
| 93 | let cursor = coll.find({ domainId, docType, docId }).limit(1); |
nothing calls this directly
no outgoing calls
no test coverage detected