mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-20 09:46:28 +08:00
remove ensureindex api (use postInit instead)
This commit is contained in:
1 parent
be9d2bffb9
commit
e62e7b49a3
13 files changed
+56
-107
No files matched your search
+12
-6
@@ -85,12 +85,18 @@ export class User implements _User {
|
||||
}
|
||||
}
|
||||
|
||||
hasPerm(p: bigint) {
|
||||
return (this.perm() & p) === p;
|
||||
hasPerm(...perm: bigint[]) {
|
||||
for (const i in perm) {
|
||||
if ((this.perm() & perm[i]) === perm[i]) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
hasPriv(p: number) {
|
||||
return !!(this.priv & p);
|
||||
hasPriv(...priv: number[]) {
|
||||
for (const i in priv) {
|
||||
if ((this.priv & priv[i]) === priv[i]) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
checkPassword(password: string) {
|
||||
@@ -215,13 +221,14 @@ export function ban(uid: number) {
|
||||
]);
|
||||
}
|
||||
|
||||
export function ensureIndexes() {
|
||||
function ensureIndexes() {
|
||||
return Promise.all([
|
||||
coll.createIndex('unameLower', { unique: true }),
|
||||
coll.createIndex('mailLower', { sparse: true }),
|
||||
]);
|
||||
}
|
||||
|
||||
global.Hydro.postInit.push(ensureIndexes);
|
||||
global.Hydro.model.user = {
|
||||
User,
|
||||
create,
|
||||
@@ -237,5 +244,4 @@ global.Hydro.model.user = {
|
||||
setPriv,
|
||||
getList,
|
||||
ban,
|
||||
ensureIndexes,
|
||||
};
|
||||
Reference in new issue
Block a user