MCPcopy Create free account
hub / github.com/hydro-dev/Hydro / add

Method add

packages/hydrooj/src/model/problem.ts:148–161  ·  view source on GitHub ↗
(
        domainId: string, pid: string = '', title: string, content: string, owner: number,
        tag: string[] = [], meta: ProblemCreateOptions = {},
    )

Source from the content-addressed store, hash-verified

146 };
147
148 static async add(
149 domainId: string, pid: string = '', title: string, content: string, owner: number,
150 tag: string[] = [], meta: ProblemCreateOptions = {},
151 ) {
152 const [doc] = await ProblemModel.getMulti(domainId, {})
153 .withReadPreference('primary')
154 .sort({ docId: -1 }).limit(1).project({ docId: 1 })
155 .toArray();
156 const result = await ProblemModel.addWithId(
157 domainId, (doc?.docId || 0) + 1, pid,
158 title, content, owner, tag, meta,
159 );
160 return result;
161 }
162
163 static async addWithId(
164 domainId: string, docId: number, pid: string = '', title: string,

Callers 3

addWithIdMethod · 0.45
copyMethod · 0.45
importMethod · 0.45

Calls 2

addWithIdMethod · 0.80
getMultiMethod · 0.45

Tested by

no test coverage detected