waterline

How to properly do a Bulk upsert/update in MongoDB

孤者浪人 提交于 2019-11-27 07:44:14
问题 I'm trying to: Find a document according to a search criteria, If found, update some attributes If not insert a document with some attributes. I'm using a Bulk.unOrderedOperation as I'm also performing a single insert. And I want to do everything in one operation againast DB. However something it's causing nothing is being inserted for the update/upsert operation. This is the insert document: var lineUpPointsRoundRecord = { lineupId: lineup.id, // String totalPoints: roundPoints, // Number

sails.js - I want to add DB connection dynamically after sails lift

梦想与她 提交于 2019-11-26 23:18:10
问题 During sails lift I don't yet have all the connection information for my DB. Is there a way to either have config values dependent on promises or dynamically create a connection after sails lift has completed? I would obviously have to add a policy or hook to handle requests to routes needing the model if it wasn't available yet, but at this point I don't see how to even let the sails lift until I already know the connection info (it must be in the configs). I'm hoping I'm missing a way to