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

Why the identifiers are duplicated in the database? _id & id #797

Closed
abdonrd opened this issue Mar 17, 2018 · 2 comments
Closed

Why the identifiers are duplicated in the database? _id & id #797

abdonrd opened this issue Mar 17, 2018 · 2 comments
Assignees

Comments

@abdonrd
Copy link
Contributor

abdonrd commented Mar 17, 2018

Why the identifiers are duplicated in the database? _id & id.

@Aurelsicoko
Copy link
Member

@abdonrd As you know, Strapi is compatible with Mongo and SQL databases. By convention, the SQL databases are using the id attribute to identify the entries. However, Mongo is using the _id as the identifier. To make the backend and frontend part uniform we partially implement the duplication of the Mongoo _id attribute.

For example, it avoids us to make this everywhere:

const entryId = this.data.user._id || this.data.user.id;

@Aurelsicoko
Copy link
Member

The final solution should to automatically handle this in the strapi-mongoose connector to make sure the _id is duplicated and also saved through the id attribute. The codebase has to work with any databases so we have to make that kind of choices. We know it's not perfect but it's an easy and working solution.

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

3 participants