Mongomapper: does the "_id" field conflict with "id"?

I have a collection that contains both _id and id. When I search by id field in mongo client, everything is fine. When I look at the mongomapper model, for example: Product.find_by_id (6) or Product.where (: id => 6), it returns an empty Plucky object, and I see that it is looking for the _id field instead of id.

As I understand it, mongomapper always uses _id, regardless of whether you want to find something by id.

Is there any work for this, or am I doing it wrong?

+3
source share
2 answers

I believe that MongoMapper considering idand _idequally. idis just a friendlier presentation _id.

- , id? , , . id (, , ), , , _id. , MongoDB ( ), .

, .

+1

(https://github.com/jnunemaker/mongomapper/issues/195), - "id". Mongo , .

0

Source: https://habr.com/ru/post/1788105/


All Articles