| 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, |