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',
…
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'},
…
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!
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,…
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…
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…
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.…
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…
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…
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":…
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:…
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…
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:…