MCPcopy Index your code
hub / github.com/hydro-dev/Hydro / push

Function push

packages/hydrooj/src/model/document.ts:191–206  ·  view source on GitHub ↗
(
    domainId: string, docType: number, docId: DocID, key: string,
    arg0: any, arg1?: any, arg2?: any,
)

Source from the content-addressed store, hash-verified

189 key: keyof DocType[K], content: string, owner: number, args?: DocType[K][T][0],
190): Promise<[DocType[K], ObjectId]>;
191export async function push(
192 domainId: string, docType: number, docId: DocID, key: string,
193 arg0: any, arg1?: any, arg2?: any,
194) {
195 const _id = arg2?._id || arg0?._id || new ObjectId();
196 const v = arg1
197 ? { _id, ...arg2, content: arg0, owner: arg1 }
198 : { _id, ...arg0 };
199 const doc = await coll.findOneAndUpdate(
200 { domainId, docType, docId },
201 // @ts-ignore
202 { $push: { [key]: v } },
203 { returnDocument: 'after' },
204 );
205 return [doc, _id];
206}
207
208export async function pull<K extends keyof DocType, T extends ArrayKeys<DocType[K]>>(
209 domainId: string, docType: K, docId: DocType[K]['docId'],

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected