sails: Unique property throws error when using mongo
Waterline version:0.13.6 Node version:10.12.0 NPM version:6.4.1 Operating system:Ubuntu 18.10
Related to - https://github.com/balderdashy/waterline/issues/1541, but no advice was given.
Currently trying to run the following code with sails-mongo. Have also tried with sails-disk and sails-memory and it is giving the same issue.
The following code results in the error: the attribute emailon theusermodel contains invalid properties. The propertyunique isn't a recognized property.
export const userCollection = Waterline.Collection.extend({
identity: 'user',
datastore: 'default',
primaryKey: 'id',
dontUseObjectIds: true,
attributes: {
id: {
type: 'string',
required: true
},
firstName: {type: 'string'},
lastName: {type: 'string'},
email: {type: 'string', required: true, unique: true}
password: {type: 'string', required: true},
roles: {
collection: 'role'
}
}
}
const sailsMongoAdapter = require('sails-mongo');
export const datastoreConfig = {
adapters: {
'mongo': sailsMongoAdapter
},
datastores: {
default: {
adapter: 'mongo',
url: 'mongodb://mongo:27017/db',
schema:true
}
},
};
waterline.initialize(datastoreConfig, (err, ontology)=> {
if (err) {
console.error(err);
throw err;
}
}
About this issue
- Original URL
- State: open
- Created 6 years ago
- Comments: 17 (4 by maintainers)
This works for me.