Tag: mongodb feathersjs

要更新MongoDB文档中的单个字段,最好的方法是什么? 在feathersjs中更新或修补钩子

我试图在单个字段中更新mongodb文档,我怀疑要使用羽化框架使用哪个补丁或更新的方法,举例说明我们如何才能做到这一点。 const { authenticate } = require('feathers-authentication').hooks; module.exports = { before: { all: [ authenticate('jwt') ], find: [], get: [], create: [], update: [], patch: [], remove: [] }, after: { all: [], find: [], get: [], create: [], update: [], patch: [], remove: [] }, error: { all: [], find: [], get: [], create: […]

mongodbfilter不工作

我试图对我的数据库运行一个查询如下: filter.customerProfile = { $exists: true }; console.log("filter: " + JSON.stringify(filter)); this.accountsAPI.find(filter, cb); 在callback我打印: console.log('first element: ', JSON.stringify(accounts[0])); 我的输出: filter: {"customerProfile":{"$exists":true}} first element: {"username":"aabrahams","firstName":"Arthur","lastName":"Abrahams","DOB":"1981-07-11","email":"aabrahams@gmail.com","adminProfile":[{"displayUsername":"Art Abrahams","active":true,"priceEdits":[],"products":[],"productEdits":[],"jobCancellationApprovals":[],"partnerApprovals":[]}],"_id":"TkJNoSogUaJFKIHU"} 基本上,它返回的所有用户,不仅是那些“customerProfile”,我用什么filter都不重要。 我试着添加“$ ne”:null,并没有帮助。

MongoDB在feathers.js中调用Hook

我想从feathers.js钩子的集合中获取信息。 我怎样才能挂钩等待,直到mongodb电话完成? 目前它没有等待电话完成发送挂钩,我试图与回报和promieses,但没有任何工作 // Connection URL const url = 'mongodb://localhost:27017/db'; //Use connect method to connect to the server module.exports = function(hook) { MongoClient.connect(url, function(err, db) { const userCollection = db.collection('question'); userCollection.count().then(function(N) { const R = Math.floor(Math.random() * N) const randomElement = userCollection.find().limit(1).skip(R).toArray(function(err, docs) { console.log("Found the following records"); console.log(docs) //update hook with data from mongodb […]