I am using waterline ORM in sails.js. I have a user model and another coins model which associates to the user model.
//coins.js
attributes: {
name: 'string',
// Associations
userId: {
model: 'user'
}
}
The query generated for this model is
CREATE TABLE `coins` (`name` VARCHAR(255) , `userId` INT , `id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, `createdAt` DATETIME , `updatedAt` DATETIME )
The query should contain foreign key constraint for userId but doesn't. Is there a workaround for this?
Currently waterline does not create foreign key constraints in the manner you describe. It only creates the associated field.
You can use a different library instead of Waterline such as Sequelize.js here is a link about how to go about doing that
https://groups.google.com/forum/#!topic/sailsjs/ALMxbKfnCIo
Or you can manually create the the constraints and the index.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With