RisingStack / graffiti-mongoose

⚠️ DEVELOPMENT DISCONTINUED - Mongoose (MongoDB) adapter for graffiti (Node.js GraphQL ORM)
https://risingstack-graffiti.signup.team/
MIT License
382 stars 52 forks source link

What is different between id and _id #201

Closed thanhlmm closed 7 years ago

thanhlmm commented 7 years ago

Overview of the Issue

I can see we can use both id or _id to query some document. But with one is refer to? I checked out in my monbodb data that it only store _id. Then id is maped base on _id ? If yes, how to generate id from _id

tothandras commented 7 years ago

Hey @nlug, _id is the mongoose identifier and id is a unique identifier across all types which is also encodes the model type. It was needed for the Relay support to have globally unique ids. https://github.com/RisingStack/graffiti-mongoose/blob/1d1f6d1d3d18c52da969ef9694c8b6a619679170/src/query/query.js#L99