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

Method createOrUpdate

packages/hydrooj/src/model/token.ts:79–89  ·  view source on GitHub ↗
(
        tokenType: number, expireSeconds: number, data: any,
    )

Source from the content-addressed store, hash-verified

77 }
78
79 static async createOrUpdate(
80 tokenType: number, expireSeconds: number, data: any,
81 ): Promise<string> {
82 const d = await TokenModel.coll.findOne({ tokenType, ...data });
83 if (!d) {
84 const res = await TokenModel.add(tokenType, expireSeconds, data);
85 return res[0];
86 }
87 await TokenModel.update(d._id, tokenType, expireSeconds, data);
88 return d._id;
89 }
90
91 @ArgMethod
92 static getSessionListByUid(uid: number) {

Callers

nothing calls this directly

Calls 2

addMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected