Questions tagged [sails-mongo]

MongoDB adapter for Sails.js

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

400 questions
0
votes
0 answers

Sails-mongo: how to add the option for maxTime(ms) for all models find query

I would like to add the option for maxTime(ms) for all models find queries, but I don't want to add them one by one in every where. Is there any easy way to implement this?
fergus
  • 1
0
votes
1 answer

Cannot add the 15th collection to Sails Mongo

I am getting a failure whenever I try to add my 15th collection. errorType': 'Error', 'errorMessage': 'Callback was already called.', 'trace': ['Error: Callback was already called.', ' at eval…
Sean
  • 13
  • 4
0
votes
1 answer

How to handle DB error in node mongoDB query?

I have a code in node - sails js mongo db code like this, it is for user signup: signup fn: try{ let err; let user = await User.create({req.body}).fetch(); if (!user){ throw new Error('Failed'); } …
Vinita
  • 1,834
  • 2
  • 8
  • 20
0
votes
1 answer

MongoDB aggregation queries in sails js

How do we write the aggregation queries in sails js other than sum and average. Like we have Model.aggregate() method in mongoose so how is the same thing done using sails-mongo
Vinita
  • 1,834
  • 2
  • 8
  • 20
0
votes
1 answer

How to use bcrypt.compare in sails js schema?

I have a user model like this: module.exports = { attributes: { email: { type: 'string', isEmail: true, unique: true, required: true }, password: { type: 'string', required: true } }, …
Vinita
  • 1,834
  • 2
  • 8
  • 20
0
votes
1 answer

Reading data from mongodb using sails js removes all collection data, why?

I have a sails js app, The following codes works fine: list: async(req, res) => { Data.find({}).exec((err, data)=>{ if(err){ res.send(500, {message: 'db error'}); } res.status(200).json({ message: 'Data List', …
Vinita
  • 1,834
  • 2
  • 8
  • 20
0
votes
0 answers

.find is not a function in sails js mongodb

I have ArticlesController.js const Articles = require('../models/Articles'); module.exports = { list: async(req, res) => { const articles = await Articles.find({}); console.log(articles); res.status(200).json({ message:…
Vinita
  • 1,834
  • 2
  • 8
  • 20
0
votes
0 answers

SailsJS MongoDB connector error: Error: Consistency violation: Unexpected error creating db connection manager: MongoError: Authentication failed

I am getting the error : error: Error: Consistency violation: Unexpected error creating db connection manager: MongoError: Authentication failed. Password is fine and I am able to connect with MongoExpress from another server and Mongo Compass. I…
mkirouac
  • 113
  • 1
  • 12
0
votes
0 answers

In sails mongo, datatype mismatch issue

Here is the request I am sending to create the record in MongoDB. StatusId datatype is an integer, but After create query DB has a string value of statusId. Don't know where I am going wrong. This is giving issue while retrieving the data from the…
charu
  • 77
  • 9
0
votes
0 answers

Promise resolves before loop completes in sails

I have a list of posts containing userId. When fetching n no.of post, I want to loop throught and get and fetch user data and append them into the post. But before the loop gets resolved, the function gets return with undefined. After that, the post…
0
votes
1 answer

Sails js, error when connect to cloud mongodb

I used cloud MongoDB in sails adapter but when I am running app, it throw an error, can someone help how to solve it? default: { adapter: 'sails-mongo', url:…
S. V
  • 1,085
  • 5
  • 5
0
votes
2 answers

Await in async function without try and catch in sails mongo db

I am using sails JS and mongo db for my web app. my code is working fine. But i am having a doubt. my database statements are like this: var a = await users.create({username:username,id:id}).fetch(); No try and catch. No error handling. it is…
Surendar
  • 153
  • 3
  • 11
0
votes
0 answers

uploading files in sails js with for loop

My requirement is for every firewall, the user is going to upload a file. That i will be uploading in memory and save the filename to mongo db. if there are 3 firewalls, only the last one is getting updated. remaining files are uploaded but location…
Surendar
  • 153
  • 3
  • 11
0
votes
1 answer

How to group documents by date when unix timestamp column?

I have following collection in mongodb [ { "createdAt": 1596700221742, "id": "5f2bb63da9babddd420d0fa6", "quoteId": "SBA0005", "commission": 0, }, { "createdAt": 1596699868976, "id":…
Prajwal
  • 319
  • 4
  • 10
0
votes
1 answer

Store the Mongodb data into variable in sails js?

I am getting undefined value of recentdate variable.When I print the value using console then It print the value successfully.When I tried to hold the value inside the variable (recentdate) then It give the undefined.I want to store the value in…