Sails: "default primary key attribute (`id`) is not set up correctly" message on console

Created on 27 Apr 2018  Â·  9Comments  Â·  Source: balderdashy/sails

Sails version: v1.0.1
Node version: v8.9.4
NPM version: 5.6.0
DB adapter name: sails-mongo
DB adapter version: 1.0.0
Operating system: Mac




Hi
Sails version: v1.0.1

at start i see this on console:

debug: It looks like the default datastore for this app is sails-mongo,
debug: but the default primary key attribute (id) is not set up correctly.
debug: When using sails-mongo, primary keys MUST have columnName: '_id',
debug: and must _not_ have autoIncrement: true.
debug: Also, if dontUseObjectIds is not set to true for the model,
debug: then the type of the primary key must be string.
debug:
debug: We'll set this up for you this time...
debug:
info: ·• Auto-migrating... (alter)
info: Hold tight, this could take a moment.
info: ✓ Auto-migration complete.

The app is working but this message is annoying

How to avoid this?

Thanks

Most helpful comment

You need to set columnName: '_id' on your default id attribute in config/models.js, see here.

All 9 comments

Hi @assiomatica! 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:

  • Provide your Sails version
  • Provide your Node version
  • Provide your NPM version
  • Provide your Operating system
  • Verify "I am experiencing a concrete technical issue (aka a bug) with Sails (ideas and feature proposals should follow the guide for proposing features and enhancements (http://bit.ly/sails-feature-guide), which involves making a pull request). If you're not 100% certain whether it's a bug or not, that's okay--you may continue. The worst that can happen is that the issue will be closed and we'll point you in the right direction."
  • Verify "I am not asking a question about how to use Sails or about whether or not Sails has a certain feature (please refer to the documentation(http://sailsjs.com), or post on http://stackoverflow.com, our Google Group (http://bit.ly/sails-google-group) or our live chat (https://gitter.im/balderdashy/sails)."
  • Verify "I have already searched for related issues, and found none open (if you found a related _closed_ issue, please link to it in your post)."
  • Verify "My issue title is concise, on-topic and polite ("jst.js being removed from layout.ejs on lift" is good; "templates dont work" or "why is sails dumb" are not so good)."
  • Verify "I have tried all the following (if relevant) and my issue remains:"
  • Verify "I can provide steps to reproduce this issue that others can follow."

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]

ok, fixed

Sorry to be a hassle, but it looks like your issue is still missing some required info. Please double-check your initial comment and try again.

*If you feel this message is in error, or you want to debate the merits of my existence (sniffle), please contact [email protected]

ok, fixed

@assiomatica Thanks for posting, we'll take a look as soon as possible.


For help with questions about Sails, click here. If you’re interested in hiring @sailsbot and her minions in Austin, click here.

You need to set columnName: '_id' on your default id attribute in config/models.js, see here.

I see, thanks!

Il giorno ven 27 apr 2018 alle 12:09 Hamza notifications@github.com ha
scritto:

You need to set columnName: '_id' on your default id attribute in
config/models.js.

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/balderdashy/sails/issues/4378#issuecomment-384927583,
or mute the thread
https://github.com/notifications/unsubscribe-auth/ACI2gT1pzIQ8zhD58utq7O-HTBfp6vOdks5tsu5zgaJpZM4Tp5tm
.

>

Antonio Casula

mobile +41 (0)79 9692274
ch.linkedin.com/in/antoniocasula/

@hamzaOp thanks!

@hamzaOp

You need to set columnName: '_id' on your default id attribute in config/models.js, see here.

It also says there:

The best way to change the primary key for your model is simply to customize the columnName of that default attribute.

which is what also causes the above message to appear.

Which, in turn, now makes me wonder what Sails is using as my primary key now, since it tells me:

We'll set this up for you this time...

But, I don't want Sails to set this up for me this time or any other, I want to freely chose my freaking primary key attribute, just like we were able to in 0.12

The amount of code I would need to change now, just because of this pointless limitation is staggering. Which means we will now never be able to upgrade Sails to 1.0..........

Was this page helpful?
0 / 5 - 0 ratings