I'm trying to migrate a Sails application previously working with Mongo to Node. So far, I've had success with operations: find, findOne and save. But I can't manage to make "create" or "findOrCreate" to work. I'm using the same query from sails waterline:
Model.create(data).exec(function(err, results){
});
But always get:
/usr/local/lib/node_modules/sails/node_modules/waterline/lib/waterline/error/WLError.js:29
this.rawStack = (this._e.stack.replace(/^Error(\r|\n)*(\r|\n)*/, ''));
Apparently, findOrCreate doesn't even exists on the connector, but create does... but can't make it work.
Any idea will be much appreciated!
UPDATE 1
This is exactly what I'm writing in the function:
Model.create({
id: uuid.v4(),
sku: params.sku
}).exec(function(err, results){
if(err) return res.status(500).send(err);
return res.status(200).send(results);
});
And I've the following on my models/Model.js file:
module.exports = {
attributes: {
id: {
type: 'string',
primaryKey: 'hash'
},
sku: {
type: 'string',
primaryKey: 'range'
},
createdAt: {
type: 'string'
},
updatedAt: {
type: 'string'
}
}
};