core: 将pid设置为可选

This commit is contained in:
undefined committed 2021-03-08 00:00:53 +08:00
1 parent a22400d247
commit 4a294f59a8
8 files changed
+9 -14

No files matched your search

+3 -4
View File
@@ -21,19 +21,18 @@ function ensureIndexes() {
}
export async function add(
tokenType: number, expireSeconds: number, data: any,
tokenType: number, expireSeconds: number, data: any, id = String.random(32),
): Promise<[string, TokenDoc]> {
const now = new Date();
const str = String.random(32);
const res = await coll.insertOne({
...data,
_id: str,
_id: id,
tokenType,
createAt: now,
updateAt: now,
expireAt: new Date(now.getTime() + expireSeconds * 1000),
});
return [str, res.ops[0]];
return [id, res.ops[0]];
}
export async function get(tokenId: string, tokenType: number): Promise<TokenDoc | null> {