Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to eliminate the "id" field on table creation and select? Postgres #7945

Closed
codeimmortal opened this issue Jul 13, 2017 · 5 comments
Closed

Comments

@codeimmortal
Copy link

when i am creating any table by sequlizer it is adding id with it . I want to to be removed.

/*global sequelize Sequelize */
module.exports = (function () {
'use strict';
var blurbs = sequelize.define('blurb', {
blurb_id: {
type: Sequelize.INTEGER
},
update_date: {
type: Sequelize.DATE
}
},
{
freezeTableName: true,
schema: 'mobile_blurb',// don't add the timestamp attributes (updatedAt, createdAt)
timestamps: false
// ,id: false
});

// // force: true will drop the table if it already exists
blurbs.sync({force: false}).then(function () {
// Table created
return true;
});
return blurbs;
}());

**The query is generated is this .

CREATE TABLE IF NOT EXISTS "mobile_blurb"."blurb" ("id" S
ERIAL , "blurb_id" INTEGER, "update_date" TIMESTAMP WITH TIME ZONE, PRIMARY KEY
("id"));

I don't need "id" field.**

@codeimmortal codeimmortal changed the title How to eliminate the "id" field on table creation and select? How to eliminate the "id" field on table creation and select? Postgres Jul 13, 2017
@ox
Copy link

ox commented Jul 13, 2017

You can remove the attribute by calling:

blurbs.removeAttribute('id');

Right after you have defined blurb.

@stale stale bot added the stale label Sep 11, 2017
@stale
Copy link

stale bot commented Sep 11, 2017

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If this is still an issue, just leave a comment 🙂

@codeimmortal
Copy link
Author

The solution worked.

@scucchiero
Copy link

Any fancier solution so far?

@papb papb reopened this Jan 15, 2020
@stale stale bot removed the stale label Jan 15, 2020
@papb
Copy link
Member

papb commented Jan 15, 2020

Duplicate of #3142

@papb papb marked this as a duplicate of #3142 Jan 15, 2020
@papb papb closed this as completed Jan 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants