Questions tagged [sails-mongo]

MongoDB adapter for Sails.js

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

400 questions
1
vote
0 answers

& not allowed in string type in sails model

//Food.js module.exports = { attributes: { foodName: { type: 'string', required: true, unique: true }, imgUrl: { type: 'string' //required: true } } }; While saving the food item If I am giving…
1
vote
1 answer

How to declare array in sails model?

I have been facing a issue which needs the array like model. my current model is module.exports = { attributes: { foodname:{ type: 'string', unique: true, required: true, }, foodreview:'string', …
divakar
  • 1,379
  • 6
  • 15
  • 31
1
vote
0 answers

Sails-Mongo connects to my database with no credentinals. How can I fix that?

I recently switched to mongodb database instead of the default disk. My MongoDB adapter: ArrowDB: { adapter: 'sails-mongo', host: 'localhost', port: 27017, user: '', password: '', database: 'ArrowDB' }, At…
Matan Gubkin
  • 3,019
  • 6
  • 25
  • 44
1
vote
1 answer

SailsJS: Prevent Model.create() if it has undeclared attributes

Is there a way to prevent an entity creation if it contains an attribute that is not declared in api/models/YourModel? For example, let's say I used MongoDB, and I have this User model: module.exports = { attributes: { name:{type:'string'}, …
Alon Amir
  • 4,913
  • 9
  • 47
  • 86
1
vote
0 answers

How can I query nested model attributes through Waterline in MongoDB?

I'm trying to do something like: filter.or = [ { name: { contains: q } }, { "location.city": { contains: q } } ]; However it seems that "location.city", trying the MongoDB query language, is not working. How can I achieve this? Thanks!
gonzalomelov
  • 971
  • 1
  • 13
  • 30
1
vote
2 answers

What type of Object does publishCreate accept?

When I use: User.publishCreate(user.id); My server logs: error: Invalid usage of publishCreate() :: Values must have an `id`, instead got :: '54fc5ebf4da88b7260445f7d' My data is being stored in MongoDB that creates an ObjectID. If I use user.id,…
Matias Faure
  • 822
  • 1
  • 9
  • 20
1
vote
2 answers

SailsJS geoNear Issues

I have been having a lot of trouble getting geoNear to work in SailsJS. In my UserController.js I am trying to make a geoNear query on the location field in my user model. It is defined as JSON with a 2d-index on it. Here is an example of the…
Zach Leighton
  • 1,939
  • 14
  • 24
1
vote
2 answers

Cannot connect to docker mongo

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…
aquavitae
  • 17,414
  • 11
  • 63
  • 106
1
vote
2 answers

Sailsjs create objects - nested creations

I have a controller which accepts an API call /task/:id/start. My controller method needs to check if Task with at id is valid and if that's valid then I need to create 2 other model instances. I need to create TaskSet and then TaskSetEvents.…
ed1t
  • 8,719
  • 17
  • 67
  • 110
1
vote
1 answer

Mongo query with regex fails when backslash\newline are present

I'm using MongoDB with Sails. db.post.find( { body: {"$regex" : /^.*twitter.*$/i }}). This query is supposed to find only posts which contain 'twitter' in their body-field. For some reason it won't find a match if a backslash is present in the…
Hedge
  • 16,142
  • 42
  • 141
  • 246
1
vote
0 answers

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

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…
senornestor
  • 4,075
  • 2
  • 33
  • 33
1
vote
1 answer

multilingual model attributes in sails js advice

I'm about to start a project that's going to require some attributes on a model to be translated and not sure what the best approach would be. One option would be to create a JSON type attribute and store the translations as { title: [{ "en":…
dottodot
  • 1,479
  • 1
  • 16
  • 24
1
vote
1 answer

Sails.js handling attribute validation errors

In Sails.js it is possible to use different database connections for models and it is easy to change database (MySQL or MongoDB). The problem arises when I want to display validation errors. These are my codes: Groups.js model ... connection:…
torayeff
  • 9,296
  • 19
  • 69
  • 103
1
vote
2 answers

Sails model validation only when updating and not while creating

While using sails validation I need some fields only to get validated while updating and not during creation. The scenario is that when the user is getting creating the i am just taking username and password and later I ask for all the remaining…
Vyper
  • 573
  • 1
  • 6
  • 17
1
vote
0 answers

Sails.js and native mongodb query

I'm trying to do the following in SailsJS (v0.10): var idToUseInBothCollections = req.body.docId; var subscriber = req.user.subscriber; db.development.find({ _id: ObjectId(idToUseInBothCollections), subscriberId:…
LuminousEagle
  • 771
  • 1
  • 5
  • 6