|
@@ -2,24 +2,32 @@
|
|
|
const _ = require('lodash');
|
|
|
const moment = require('moment');
|
|
|
const { CrudService } = require('naf-framework-mongoose/lib/service');
|
|
|
-
|
|
|
+const fs = require('fs');
|
|
|
class UtilService extends CrudService {
|
|
|
constructor(ctx) {
|
|
|
super(ctx);
|
|
|
this.mq = this.ctx.mq;
|
|
|
}
|
|
|
async utilMethod(query, body) {
|
|
|
- const res = await this.ctx.model.Dock.aggregate([
|
|
|
- {
|
|
|
- $lookup: {
|
|
|
- from: 'dock_pw',
|
|
|
- localField: '_id',
|
|
|
- foreignField: 'dock_id',
|
|
|
- as: 'pw',
|
|
|
- },
|
|
|
- },
|
|
|
- ]);
|
|
|
- return res;
|
|
|
+ const path = 'C:\\Users\\liuruifeng\\Desktop\\temp\\export\\live_news_roadshow.json';
|
|
|
+ let text = await fs.readFileSync(path, { encoding: 'utf-8' });
|
|
|
+ text = JSON.parse(text);
|
|
|
+ for (const obj of text) {
|
|
|
+ const { dock_id } = obj;
|
|
|
+ if (dock_id) { obj.dock_id = { $oid: dock_id }; }
|
|
|
+ }
|
|
|
+ await fs.writeFileSync('C:\\Users\\liuruifeng\\Desktop\\temp\\export\\live_news_roadshow-rewrite.json', JSON.stringify(text));
|
|
|
+ // const eupath = 'C:\\Users\\liuruifeng\\Desktop\\temp\\export\\expert,s_user.json';
|
|
|
+ // let eutext = await fs.readFileSync(eupath, { encoding: 'utf-8' });
|
|
|
+ // eutext = JSON.parse(eutext);
|
|
|
+ // console.log(eutext.length);
|
|
|
+ // for (const obj of text) {
|
|
|
+ // if (_.isObject(obj.password)) continue;
|
|
|
+ // const { password } = obj;
|
|
|
+ // obj.password = { secret: password, mech: 'plain', createdAt: { $date: '2020-09-27T07:48:05.643Z' }, updatedAt: { $date: '2020-09-27T07:48:05.643Z' } };
|
|
|
+ // }
|
|
|
+ // await fs.writeFileSync('C:\\Users\\liuruifeng\\Desktop\\temp\\export\\role-5-rewrite.json', JSON.stringify(text));
|
|
|
+
|
|
|
}
|
|
|
|
|
|
dealQuery(query) {
|