mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 01:38:19 +08:00
core: 将pid设置为可选
This commit is contained in:
1 parent
a22400d247
commit
4a294f59a8
8 files changed
+9
-14
No files matched your search
@@ -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> {
|
||||
|
||||
Reference in new issue
Block a user