我正在通过feathers-mongo使用FeathersJS和MondoDB
我想以某种方式将useUnifiedToplogy:true传递给连接器的设置,但是它似乎没有在生成的服务(feathers generate service)中公开。
这是我的logging.class.ts
import { Db } from 'mongodb';
import { Service, MongoDBServiceOptions } from 'feathers-mongodb';
import { Application } from '../../declarations';
import {Paginated, Params} from "@feathersjs/feathers";
export class Logging extends Service {
constructor(options: Partial<MongoDBServiceOptions>, app: Application) {
super(options);
const client: Promise<Db> = app.get('mongoClient');
client.then(db => {
this.Model = db.collection('users');
});
}
};发布于 2019-12-08 07:00:15
在root有一个mongodb.ts
import { MongoClient } from 'mongodb';
import { Application } from './declarations';
export default function (app: Application) {
const connection = app.get('mongodb');
const database = connection.substr(connection.lastIndexOf('/') + 1);
const mongoClient = MongoClient.connect(connection, { useNewUrlParser: true, useUnifiedTopology: true })
.then(client => client.db(database));
app.set('mongoClient', mongoClient);
}https://stackoverflow.com/questions/59230022
复制相似问题