Hello yarn berry

This commit is contained in:
undefined committed 2021-05-26 23:35:36 +08:00
1 parent 04a4306895
commit 782f334a27
62 files changed
+448 -239

No files matched your search

+1 -1
View File
@@ -16,7 +16,7 @@ class BlackListModel {
const res = await coll.findOneAndUpdate(
{ _id: id },
{ $set: { expireAt } },
{ upsert: true, returnOriginal: false },
{ upsert: true, returnDocument: 'after' },
);
return res.value;
}
+17 -17
View File
@@ -100,7 +100,7 @@ export async function set<K extends keyof DocType>(
const res = await coll.findOneAndUpdate(
{ domainId, docType, docId },
update,
{ returnOriginal: false, upsert: true },
{ returnDocument: 'after', upsert: true },
);
return res.value;
}
@@ -141,7 +141,7 @@ export async function inc<K extends keyof DocType>(
const res = await coll.findOneAndUpdate(
{ domainId, docType, docId },
{ $inc: { [key]: value } },
{ returnOriginal: false },
{ returnDocument: 'after' },
);
return res.value;
}
@@ -153,7 +153,7 @@ export async function incAndSet<K extends keyof DocType>(
const res = await coll.findOneAndUpdate(
{ domainId, docType, docId },
{ $inc: { [key]: value }, $set: args },
{ returnOriginal: false },
{ returnDocument: 'after' },
);
return res.value;
}
@@ -183,7 +183,7 @@ export async function push(
const doc = await coll.findOneAndUpdate(
{ domainId, docType, docId },
{ $push: { [key]: v } },
{ returnOriginal: false },
{ returnDocument: 'after' },
);
return [doc.value, _id];
}
@@ -195,7 +195,7 @@ export async function pull<K extends keyof DocType, T extends ArrayKeys<DocType[
const res = await coll.findOneAndUpdate(
{ domainId, docType, docId },
{ $pull: { [setKey]: { $in: contents } } },
{ returnOriginal: false },
{ returnDocument: 'after' },
);
return res.value;
}
@@ -208,7 +208,7 @@ export async function deleteSub<T extends keyof DocType, K extends ArrayKeys<Doc
const res = await coll.findOneAndUpdate(
{ domainId, docType, docId },
{ $pull: { [key]: { _id: { $in: subId } } } },
{ returnOriginal: false },
{ returnDocument: 'after' },
);
return res.value;
}
@@ -244,7 +244,7 @@ export async function setSub<T extends keyof DocType, K extends ArrayKeys<DocTyp
[key]: { $elemMatch: { _id: subId } },
},
{ $set },
{ returnOriginal: false },
{ returnDocument: 'after' },
);
return res.value;
}
@@ -256,7 +256,7 @@ export async function addToSet<T extends keyof DocType, K extends ArrayKeys<DocT
const res = await coll.findOneAndUpdate(
{ domainId, docType, docId },
{ $addToSet: { [setKey]: content } },
{ returnOriginal: false },
{ returnDocument: 'after' },
);
return res.value;
}
@@ -285,7 +285,7 @@ export async function setStatus<K extends keyof DocStatusType>(
const res = await collStatus.findOneAndUpdate(
{ domainId, docType, docId, uid },
{ $set: args },
{ upsert: true, returnOriginal: false },
{ upsert: true, returnDocument: 'after' },
);
return res.value;
}
@@ -308,7 +308,7 @@ export async function setIfNotStatus<T extends keyof DocStatusType, K extends ke
const res = await collStatus.findOneAndUpdate(
{ domainId, docType, docId, uid },
{ $set: { [key]: value, ...args } },
{ upsert: true, returnOriginal: false },
{ upsert: true, returnDocument: 'after' },
);
return res.value;
}
@@ -322,7 +322,7 @@ export async function setStatusIfNotCondition<T extends keyof DocStatusType>(
const res = await collStatus.findOneAndUpdate(
{ domainId, docType, docId, uid },
{ $set: args },
{ upsert: true, returnOriginal: false },
{ upsert: true, returnDocument: 'after' },
);
return res.value;
}
@@ -336,7 +336,7 @@ export async function cappedIncStatus<T extends keyof DocStatusType>(
const res = await collStatus.findOneAndUpdate(
{ domainId, docType, docId, uid, [key]: { $not } },
{ $inc: { [key]: value } },
{ upsert: true, returnOriginal: false },
{ upsert: true, returnDocument: 'after' },
);
return res.value;
}
@@ -348,7 +348,7 @@ export async function incStatus<T extends keyof DocStatusType>(
const res = await collStatus.findOneAndUpdate(
{ domainId, docType, docId, uid },
{ $inc: { [key]: value } },
{ upsert: true, returnOriginal: false },
{ upsert: true, returnDocument: 'after' },
);
return res.value;
}
@@ -360,13 +360,13 @@ export async function revPushStatus<T extends keyof DocStatusType>(
let res = await collStatus.findOneAndUpdate(
{ domainId, docType, docId, uid, [`${key}.${id}`]: value[id] },
{ $set: { [`${key}.$`]: value }, $inc: { rev: 1 } },
{ returnOriginal: false },
{ returnDocument: 'after' },
);
if (!res.value) {
res = await collStatus.findOneAndUpdate(
{ domainId, docType, docId, uid },
{ $push: { [key]: value }, $inc: { rev: 1 } },
{ upsert: true, returnOriginal: false },
{ upsert: true, returnDocument: 'after' },
);
}
return res.value;
@@ -378,7 +378,7 @@ export async function revInitStatus<T extends keyof DocStatusType>(
const res = await collStatus.findOneAndUpdate(
{ domainId, docType, docId, uid },
{ $inc: { rev: 1 } },
{ upsert: true, returnOriginal: false },
{ upsert: true, returnDocument: 'after' },
);
return res.value;
}
@@ -389,7 +389,7 @@ export async function revSetStatus<T extends keyof DocStatusType>(
): Promise<any> {
const filter = { domainId, docType, docId, uid, rev };
const update = { $set: args, $inc: { rev: 1 } };
const res = await collStatus.findOneAndUpdate(filter, update, { returnOriginal: false });
const res = await collStatus.findOneAndUpdate(filter, update, { returnDocument: 'after' });
return res.value;
}
+3 -3
View File
@@ -80,7 +80,7 @@ class DomainModel {
static async edit(domainId: string, $set: Partial<DomainDoc>) {
await bus.serial('domain/before-update', domainId, $set);
const result = await coll.findOneAndUpdate({ _id: domainId }, { $set }, { returnOriginal: false });
const result = await coll.findOneAndUpdate({ _id: domainId }, { $set }, { returnDocument: 'after' });
await bus.serial('domain/update', domainId, $set, result.value);
return result.value;
}
@@ -92,7 +92,7 @@ class DomainModel {
// FIXME
// @ts-expect-error
{ $inc: { [field]: n } },
{ returnOriginal: false },
{ returnDocument: 'after' },
);
return res.value[field];
}
@@ -113,7 +113,7 @@ class DomainModel {
@ArgMethod
static async setUserRole(domainId: string, uid: MaybeArray<number>, role: string) {
if (!(uid instanceof Array)) {
const res = await collUser.findOneAndUpdate({ domainId, uid }, { $set: { role } }, { upsert: true, returnOriginal: false });
const res = await collUser.findOneAndUpdate({ domainId, uid }, { $set: { role } }, { upsert: true, returnDocument: 'after' });
const udoc = await UserModel.getById(domainId, uid);
deleteUserCache(udoc);
return res;
+1 -1
View File
@@ -46,7 +46,7 @@ class MessageModel {
const result = await coll.findOneAndUpdate(
{ _id: messageId },
{ $bit: { flag: { xor: flag } } },
{ returnOriginal: false },
{ returnDocument: 'after' },
);
return result.value;
}
+1 -1
View File
@@ -19,7 +19,7 @@ class OauthModel {
const res = await coll.findOneAndUpdate(
{ _id },
{ $set: { value } },
{ upsert: true, returnOriginal: false },
{ upsert: true, returnDocument: 'after' },
);
return res.value.uid;
}
+1 -1
View File
@@ -132,7 +132,7 @@ class RecordModel {
const res = await RecordModel.coll.findOneAndUpdate(
{ _id, domainId },
$update,
{ returnOriginal: false },
{ returnDocument: 'after' },
);
return res.value;
}
+2 -2
View File
@@ -35,7 +35,7 @@ export class StorageModel {
}
static async get(path: string, savePath?: string) {
const { value } = await StorageModel.coll.findOneAndUpdate({ path }, { $set: { lastUsage: new Date() } }, { returnOriginal: false });
const { value } = await StorageModel.coll.findOneAndUpdate({ path }, { $set: { lastUsage: new Date() } }, { returnDocument: 'after' });
if (value) return await storage.get(value._id, savePath);
return await storage.get(path, savePath);
}
@@ -61,7 +61,7 @@ export class StorageModel {
}
static async getMeta(path: string) {
const { value } = await StorageModel.coll.findOneAndUpdate({ path }, { $set: { lastUsage: new Date() } }, { returnOriginal: false });
const { value } = await StorageModel.coll.findOneAndUpdate({ path }, { $set: { lastUsage: new Date() } }, { returnDocument: 'after' });
if (!value) return null;
return {
...value.meta,
+7 -7
View File
@@ -15,22 +15,22 @@ export function get(key: string): any {
export function getMany<
A extends keyof SystemKeys, B extends keyof SystemKeys,
>(keys: [A, B]): [SystemKeys[A], SystemKeys[B]];
>(keys: [A, B]): [SystemKeys[A], SystemKeys[B]];
export function getMany<
A extends keyof SystemKeys, B extends keyof SystemKeys, C extends keyof SystemKeys,
>(keys: [A, B, C]): [SystemKeys[A], SystemKeys[B], SystemKeys[C]];
>(keys: [A, B, C]): [SystemKeys[A], SystemKeys[B], SystemKeys[C]];
export function getMany<
A extends keyof SystemKeys, B extends keyof SystemKeys, C extends keyof SystemKeys,
D extends keyof SystemKeys,
>(keys: [A, B, C, D]): [SystemKeys[A], SystemKeys[B], SystemKeys[C], SystemKeys[D]];
>(keys: [A, B, C, D]): [SystemKeys[A], SystemKeys[B], SystemKeys[C], SystemKeys[D]];
export function getMany<
A extends keyof SystemKeys, B extends keyof SystemKeys, C extends keyof SystemKeys,
D extends keyof SystemKeys, E extends keyof SystemKeys,
>(keys: [A, B, C, D, E]): [SystemKeys[A], SystemKeys[B], SystemKeys[C], SystemKeys[D], SystemKeys[E]];
>(keys: [A, B, C, D, E]): [SystemKeys[A], SystemKeys[B], SystemKeys[C], SystemKeys[D], SystemKeys[E]];
export function getMany<
A extends keyof SystemKeys, B extends keyof SystemKeys, C extends keyof SystemKeys,
D extends keyof SystemKeys, E extends keyof SystemKeys, F extends keyof SystemKeys,
>(keys: [A, B, C, D, E, F]): [SystemKeys[A], SystemKeys[B], SystemKeys[C], SystemKeys[D], SystemKeys[E], SystemKeys[F]];
>(keys: [A, B, C, D, E, F]): [SystemKeys[A], SystemKeys[B], SystemKeys[C], SystemKeys[D], SystemKeys[E], SystemKeys[F]];
export function getMany(keys: (keyof SystemKeys)[]): any[];
export function getMany(keys: string[]): any[] {
return keys.map((key) => cache[key]);
@@ -43,7 +43,7 @@ export async function set(_id: string, value: any, boardcast = true) {
const res = await coll.findOneAndUpdate(
{ _id },
{ $set: { value } },
{ upsert: true, returnOriginal: false },
{ upsert: true, returnDocument: 'after' },
);
cache[_id] = res.value.value;
return res.value.value;
@@ -55,7 +55,7 @@ export async function inc<K extends NumberKeys<SystemKeys>>(_id: K) {
// FIXME NumberKeys<>
// @ts-ignore
{ $inc: { value: 1 } },
{ upsert: true, returnOriginal: false },
{ upsert: true, returnDocument: 'after' },
);
cache[_id] = res.value.value;
return res.value.value;
+1 -1
View File
@@ -53,7 +53,7 @@ class TokenModel {
tokenType,
},
},
{ returnOriginal: false },
{ returnDocument: 'after' },
);
return res.value;
}
+3 -3
View File
@@ -204,7 +204,7 @@ class UserModel {
const op: any = {};
if ($set && Object.keys($set).length) op.$set = $set;
if ($unset && Object.keys($unset).length) op.$unset = $unset;
const res = await coll.findOneAndUpdate({ _id: uid }, op, { returnOriginal: false });
const res = await coll.findOneAndUpdate({ _id: uid }, op, { returnDocument: 'after' });
deleteUserCache(res.value);
return res;
}
@@ -220,7 +220,7 @@ class UserModel {
const res = await coll.findOneAndUpdate(
{ _id: uid },
{ $set: { salt, hash: pwhash(password, salt), hashType: 'hydro' } },
{ returnOriginal: false },
{ returnDocument: 'after' },
);
deleteUserCache(res.value);
return res.value;
@@ -290,7 +290,7 @@ class UserModel {
const res = await coll.findOneAndUpdate(
{ _id: uid },
{ $set: { priv } },
{ returnOriginal: false },
{ returnDocument: 'after' },
);
deleteUserCache(res.value);
return res.value;