sails-mongo

How to extract distinct values from a mongo database using Waterline and Sails.js (version 0.10)?

╄→гoц情女王★ 提交于 2019-12-12 09:58:42
问题 Using Sails.js version 0.10.x , assume I have a model Dog , populated as follows (writtenout in yaml format for convenience, but in my case it's actually in a mongo database.) dogs: - breed: "wolf" name: "Fido" - breed: "wolf" name: "Roger" - breed: "dingo" name: "Nipper" - breed: "dingo" name: "Ernie" - breed: "corgi" name: "Bernadi" - breed: "corgi" name: "Queenie" - breed: "poodle" name: "Christopher" - breed: "poodle" name: "Tony" etc So now I want to create a list of the available breeds

How to implement many to many association using through in Sails?

戏子无情 提交于 2019-12-12 02:43:29
问题 I'm using Sails v0.11.2 and MongoDB 3.2 on Mac OS X El Capitan and I'm trying to implement Many-To-Many association using Through option which isn't supported yet. However, googling I found this Waterline Github Issue and elennaro , a github user, gave me a couple of links with some examples: First one Second one I have tried to adapt them to my own Sails app but I can't make it works. I got no errors on the console but the record or document on the intermediary table is not created only the

in sailsjs , 403 “You don't have permission to see the page you're trying to reach” error produce when adding new pages ,controllers and models

时光怂恿深爱的人放手 提交于 2019-12-11 23:45:24
问题 First i run my sails project in local , after i pushed in git repo and then i changed in online and then pushed in remote place. then i downloaded in my local. This changes produce permission problem. that is "You don't have permission to see the page you're trying to reach" this error caused while i was inserting data in mongo. what i should do ? i want get output back 回答1: This is a guess since I'm not sure what your code looks like but I'm guessing you haven't included the following CSRF

Sails.js many-to-many associations throw error on create and populate

这一生的挚爱 提交于 2019-12-11 09:17:04
问题 When I try to associate one collection with another collection using a many-to-many association, I get the following error: Using sails-mongo: TypeError: Cannot read property 'where' of undefined at _afterFetchingJunctorRecords (/Users/grant/Sites/sails/test/node_modules/sails-mongo/node_modules/waterline-cursor/cursor/populateBuffers.js:131:35) at /Users/grant/Sites/sails/test/node_modules/sails-mongo/lib/collection.js:103:5 at /Users/grant/Sites/sails/test/node_modules/sails-mongo/node

Cannot connect to docker mongo

↘锁芯ラ 提交于 2019-12-11 04:33:11
问题 I am setting up a project using sane with docker. After creating the project to use mongodb and createing a resource I tried running it, but got an error reporting that the server container could not connect to mongo. I then tried just running fig up to see if it was a fig problem and got the same error. Here is my fig.yml (irrelevant comments removed): db: image: mongo:latest ports: - "27017:27017" server: image: artificial/docker-sails:stable-pm2 command: sails lift volumes: - server/:

Why wouldn't a waterline callback happen to be triggered?

一曲冷凌霜 提交于 2019-12-11 04:25:02
问题 I'm using Sails built in models and it's ORM to perform MongoDB queries and operations. The problem I got is that, for some query methods,it's callback is never being called. The DB operation gets done, but callback won't come up. Following code snippet is model querying part of a controller method for an API, that's why I'm using a response object. LineUp.update({ id: request.param('id') }, { players: [], budgetLeft: 60000000 }). exec(function (err, lineup) { console.log("Should happen");

sails-mongo adapter, normalize error messages

时间秒杀一切 提交于 2019-12-10 20:49:24
问题 I am trying out sailsJs with mongodb using the sails-mongo adapter. After adding validations to a model, I get the following response when the validation fails. Users.js Model: module.exports = { schema: true, attributes: { name: { type: "string", unique: true }, email: { type: "email", unique: true }, password: { type: "string", required: true } } } Validation error while using sails-mongo adapter: { "error": { "error": "E_UNKNOWN", "status": 500, "summary": "Encountered an unexpected error"

Waterline (Sails.js): AND conditions

百般思念 提交于 2019-12-08 04:14:17
问题 I'm using mongodb with sails.js querying a model that contains the titles of torrent files. But I'm not able to perform a waterline query using the "AND" condition. I've already tried it in several ways but most of them return empty or simply, never return. e.g. the database contains an entry with: "title": "300 Rise Of An Empire 2014 720p BluRay x264-BLOW [Subs Spanish Latino] mkv" When adding each query parameter line by line: var query = Hash.find(); query = query.where({ "title": {

Waterline MongoDb (populated) fetched object looses its type AND prototype functions

主宰稳场 提交于 2019-12-08 02:13:51
问题 I'm using sails with mongo db over waterline. Lets say that I declare 2 models in my sails project like so : A user model @ models/User.js simplified: username: { type: 'string', unique: true }, passports: { collection: 'Passport', via: 'owner' }, aUserFunction: function(){ console.log('I'm a user function'); } and a passport model @ models/Passport.js simplified: password: { type: 'string' }, owner: { model: 'User', required: true }, aPassportFunction: function(){ console.log('I'm a passport

Sails.js upgrade to v1 reverse case sensitive queries

試著忘記壹切 提交于 2019-12-08 01:32:08
问题 After upgrading to sails v1 all the requests in the controllers became case sensitive. Although this is expected, commented here: https://sailsjs.com/documentation/concepts/models-and-orm/models#?case-sensitivity, I would like to have case insensitive behavior. In my queries this is a problem and I am not able to figure out a way to make it NON case sensitive again. I am using MongoDB in production. Any kind of help or suggestion would be much appreciated. 回答1: For MongoDB we need to do a