Questions tagged [sails-mongo]

MongoDB adapter for Sails.js

Sails-mongo allows connecting to from using the ORM api.

400 questions
2
votes
1 answer

How can I validate a record only without saving in nodejs | sailsjs | waterline

I seek something of this nature //validation rules in model "User" attributes: { age: { required: true, type: 'numeric' } }, //now in controller, i want to be able to do this Recipe.validate({age: 'An invalid age because…
yomexzo
  • 665
  • 1
  • 6
  • 22
2
votes
2 answers

Sails 10.x waterline: What attribute type to use for Mongo objectID

sailsjs: I am trying to define a model. I would like to add a property vendorID. The type would be the monogdb objectID from the vendor collection. Something like for a store model: module.exports ={ attributes :{ vendorId : { type:
tomatom
  • 419
  • 4
  • 9
2
votes
3 answers

How to select document by id with Sails-mongo?

User.find({ _id: { '!': user.id } }, function foundFriends (err, friends) { if(err) return next(err); res.view({ friends: friends }); }); MONGODB : { _id: ObjectId("53b942f7c8638f7b17670acc"), name: "PH", …
PH-neutre
  • 31
  • 4
2
votes
1 answer

MongoDB Query group and distinct together

Consider the following set of documents: [ { "name" : "nameA", "class" : "classA", "age" : 24, "marks" : 45 }, { "name" : "nameB", "class" : "classB", "age" : 22, "marks" : 65 }, { "name" : "nameC", …
Sambhav Sharma
  • 5,741
  • 9
  • 53
  • 95
2
votes
1 answer

Waterline.js: Populate association from list

Does anyone know if it's possible to populate a list of IDs for another model using waterline associations? I was trying to get the many-to-many association working but I don't think it applies here since one side of the relationship doesn't know…
Jason Sims
  • 1,148
  • 2
  • 10
  • 22
2
votes
2 answers

sails v0.10.0-rc7 unique constraint not working

I upgraded my sails from rc4 to rc7 today, and the unique constraint on my model stopped working. note that in rc4 it used to work perfectly. and sails-mongo version on both versions i tried is: "sails-mongo": "^0.10.0-rc5" Model attribute: …
2
votes
2 answers

Do I need to do anything special to my application built with Sails version 0.9.9 when upgrading to version 0.10.x?

I am currently working on an application using Sails version 0.9.9 but I want to upgrade to utilize the new support for data model associations. I found this article about migrating applications from 0.8.x to 0.9.x but is there anything I should do…
2
votes
2 answers

How do I rename all the fields in my database schema using Sails.js, sails-mong and Mongo DB

I have a sails app using sails-mongo and mongo db ... in the Database schema I originally named on of the fields 'name', I've since named the same key in other data types 'deviceName'. I would like to rename all of the records so that the field is…
user379468
  • 3,989
  • 10
  • 50
  • 68
1
vote
1 answer

Failed to filter array of data based on there condition

I want to retrieve based on their list of IDs given. There is a list of ids I used inside my controller I want to retrieve all the objects array based on the given list of ids to me here is a prototype of my database record how it looks like [ { …
Developer Nans
  • 311
  • 1
  • 4
  • 14
1
vote
0 answers

Sails.js default app fails to start with MongoDb

I created a WebApp with sails new my-app and am trying to use mongodb as its database. I am running mongodb in docker and am able to connect to the database using GUI tools like MongoDB Compass. Using that tool I created todo_list database in…
Andrey
  • 20,487
  • 26
  • 108
  • 176
1
vote
2 answers

Sails-mongo not working with MongoDB Atlas URI

I was trying with the below configs : In datastores.js I tried adapter: 'sails-mongo', url: 'mongodb+srv://xyz@cluster0.uaxyh.mongodb.net/xyz?retryWrites=true&w=majority', ssl: true The above URL is for MongoDB Atlas In model.js id: { type:…
CandleCoder
  • 1,387
  • 4
  • 21
  • 45
1
vote
3 answers

Sails, EJS data is not defined in forEach loop

I am working on Sails.js CRUD application (article management) with MongoDB based on @bradtraversy tutorial. I have encountered issue while trying to display articles from the database using EJS syntax and forEach loop. Error says "articles data is…
Ambrozy
  • 19
  • 2
1
vote
1 answer

Migrate data in mongodb from old schema to new schema via sailsjs

I want to migrate the schema of my models. I wanted to try to do so with the "migrate: alter" command in my env file. The problem seems to be that on default the startup script will run in production mode which automatically uses "migrate:…
crick
  • 13
  • 2
1
vote
1 answer

Problem authenticating with mocha, chai and supertest

I add the userRecord to the database in the before function but when I try to authenticate using supertest it gives me bad combo. I am using sails for the backend, the code is as follows var request = require('supertest'); let should =…
Vikranth
  • 1,538
  • 1
  • 14
  • 23
1
vote
0 answers

Get connection status of my database in sails v0.12

I want to get the equivalent of db.serverStatus() command in mongo shell for Sails v0.12. In v1.0 I think they have sails.getDatastore for this. I searched the documentation for v0.12 and could not get an alternative. Is it possible to check the…
Ashwin Sreekumar
  • 121
  • 1
  • 12