core: 忽略域id中大小写差异

This commit is contained in:
undefined committed 2021-06-27 21:30:12 +08:00
1 parent bff392e73f
commit b13b8835ec
3 files changed
+9 -2

No files matched your search

+3 -1
View File
@@ -45,6 +45,7 @@ class DomainModel {
static async add(domainId: string, owner: number, name: string, bulletin: string) {
const ddoc: DomainDoc = {
_id: domainId,
lower: domainId.toLowerCase(),
owner,
name,
bulletin,
@@ -59,7 +60,7 @@ class DomainModel {
@ArgMethod
static async get(domainId: string): Promise<DomainDoc | null> {
const query: FilterQuery<DomainDoc> = { _id: domainId };
const query: FilterQuery<DomainDoc> = { lower: domainId.toLowerCase() };
await bus.serial('domain/before-get', query);
const result = await coll.findOne(query);
await bus.serial('domain/get', result);
@@ -274,5 +275,6 @@ class DomainModel {
}
}
bus.on('app/started', () => coll.createIndex({ lower: 1 }, { unique: true }));
export default DomainModel;
global.Hydro.model.domain = DomainModel;
+5
View File
@@ -423,6 +423,11 @@ const scripts: UpgradeScript[] = [
});
return true;
},
async function _34_35() {
const _FRESH_INSTALL_IGNORE = 1;
await iterateAllDomain((ddoc) => domain.edit(ddoc._id, { lower: ddoc._id.toLowerCase() }));
return true;
},
];
export default scripts;