mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-18 01:36:08 +08:00
core: fix api projection
This commit is contained in:
2 files changed
+2
-2
No files matched your search
@@ -126,7 +126,7 @@ export class ApiService extends Service {
|
||||
await emitHook?.(`api/before/${callOrName}`, args);
|
||||
}
|
||||
const result = await func(context, args as any);
|
||||
return project ? projection(result, project) : result;
|
||||
return (project && typeof result === 'object' && result !== null) ? projection(result, project) : result;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -609,7 +609,7 @@ export const coreScripts: MigrationScript[] = [
|
||||
const docs = await c.oauth.coll.find({ id: { $type: 'number' as any } }).toArray();
|
||||
const op = c.oauth.coll.initializeUnorderedBulkOp();
|
||||
for (const doc of docs) {
|
||||
op.find({ _id: doc._id }).updateOne({ id: doc.id.toString() });
|
||||
op.find({ _id: doc._id }).updateOne({ $set: { id: doc.id.toString() } });
|
||||
}
|
||||
if (op.length) await op.execute();
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user