Waterline version:0.13.3
Node version: 5.8.0
NPM version:9.11.1
Operating system: Zen Arch Linux
I am trying to create an autoincrement property in my waterline model definition. when i do and i run my server i get into this error The attribute ``id`` on the ``ownershipchangeaction`` model contains invalid properties. The property ``autoIncrement`` isn't a recognized property. where ownershipchangeaction is my model's name.
I am using the sails-mysql adapter. How can i make an automatically incremented column in waterline ? am i missing something ?
here is my model :
var OwnerShipChangeAction = Waterline.Collection.extend({
identity: 'ownershipchangeaction',
datastore: 'default',
primaryKey: 'id',
attributes: {
id: {type:'number',autoIncrement:true},
cert: {type:'string'},
iss : {type:'string'},
fiss :{type:'string'},
owner :{type:'string'},
createdAt: { type: 'number', autoCreatedAt: true, },
updatedAt: { type: 'number', autoUpdatedAt: true, },
}
});
i get this when i remove the autoincrement property :
Error: In model ``ownershipchangeaction``, primary key ``id`` must have either ``required`` or ``autoIncrement`` set.
Hi @moda20! It looks like you missed a step or two when you created your issue. Please edit your comment (use the pencil icon at the top-right corner of the comment box) and fix the following:
As soon as those items are rectified, post a new comment (e.g. “Ok, fixed!”) below and we'll take a look. Thanks!
*If you feel this message is in error, or you want to debate the merits of my existence (sniffle), please contact [email protected]
Seeing this as well.
@cdeveas Yes and I am seeing a lot of miss-documentations .
I did solve this by using it this way : autoMigrations:{autoIncrement:true}
and I am having problems with setting the ColumnType too.
The official documentation is way OLD and not regularly updated, especially for Standalone waterline.
@moda20 I did like a lot of features of Waterline, but the latest version seems to depend heavily on Sails (understandably). I ended up going with TypeORM for my small project. There's an ES6 non-typescript example implementation here: https://github.com/typeorm/javascript-example
_Apologies for mentioning another ORM within a waterline Issue_
@moda20 @chasdevs looks like you got it under control with the autoMigrations. For reference to others viewing this issue, documentation here:
https://sailsjs.com/documentation/concepts/models-and-orm/standalone-waterline-usage
@moda20 feel free to update the issue with a specific question re: columnType. Did you take a look at this yet? https://sailsjs.com/documentation/concepts/models-and-orm/attributes#columntype
@oaksofmamre @chasdevs @moda20 - Hey everyone, we're currently in the process of moving all the Waterline cases to Sails (balderdashy/sails) for greater exposure. We appreciate all the effort put into solving this one and welcome any further updates or related feedback. Thanks.
@pranay-sonisoft @calvin-evans @moda20 Hey y'all just to wrap this up, and for anyone finding this issue in the future, here are the takeaways:
autoMigrations, but that won't do anything outside of the context of Sails. If you're doing something very custom and want to use automigrations on their own, it's technically possible (see the waterline-utils package), though I wouldn't recommend it because it's unconventional.Thanks everyone for the help!
Most helpful comment
@cdeveas Yes and I am seeing a lot of miss-documentations .
I did solve this by using it this way :
autoMigrations:{autoIncrement:true}and I am having problems with setting the
ColumnTypetoo.The official documentation is way OLD and not regularly updated, especially for Standalone waterline.