surender
surender

Reputation: 1

Mongo Documents with ObjectId is not being updated and create new document with Mongo.ObjectId

I am using react-native-meteor package to connect with meteor.My Mongodb collection contains document with ObjectId. When I get the collection in react-native client side, all my ObjectId is converted to string by default. Thus making me difficult to perform operation like update from react-native client side.

When I perform insert operation in react-native client side, The insert command creates _id as string while I want _id as Object ID.

Is there any method or class in this package(react-native-meteor) to convert _id to Obejct ID in react-native client side.

Upvotes: 0

Views: 489

Answers (1)

Convert String to ObjectID MongoDB & NodeJS

var ObjectID = require('mongodb').ObjectID; // convert string to ObjectID in mongodb then I am able to convert string to ObjectId in nodejs mongodb native drive.

Upvotes: 0

Related Questions