Questions tagged [objectid]

The ID of an object. This is used, among other reasons, to refer back to the object at a later time in the program

Used especially in web programming where space on the stack is limited, objectids are used to refer to objects at different parts of the program, and possibly even across different user sessions, if some marshalling is implemented (as databases, etc).

The ID of an object can also be used to determine if two objects are distinct instances or are indeed the same object, in which case, any modifications made on one would be reflected in the other as well

481 questions
3
votes
1 answer

Using Mongo / BSON ObjectId with Parse Server

I currently have a project that's being migrated away from Parse Server but needs to maintain backwards compatibility. Since Parse Server generates it's own object Ids, rather than using Mongo's I'd like to know: How does Parse Server generate it's…
James
  • 615
  • 1
  • 4
  • 22
3
votes
0 answers

$pulling an object from an array based on _id in Mongoose

I am trying to delete an object from an array based on its _id field like so: (posts is an array of objects) User.findOneAndUpdate( { id: req.params.userid }, { $pull: { 'posts': { 'posts._id': { $eq: req.body.postID } } } }, {…
JohnSnow
  • 6,911
  • 8
  • 23
  • 44
3
votes
1 answer

negative process id in object id

Add some records to collection with java driver, it will generate object id for each records automatically. In my database, it generate below Object Id by MongoDB: ObjectId("58b38cd57decdd8070b2df8f") Then I make a test for current object…
Kimi Liu
  • 33
  • 4
3
votes
1 answer

MongoDB efficient way to search for objectId field with null using Index?

I am trying to find an efficient way to search for items in which specific field is null. In the MongoDB, I have folder schema which has parent field of its parent folder's ObjectId and parent is indexed. For root folders, parent fields are…
Satoko
  • 133
  • 5
3
votes
1 answer

Sails and subdocument ObjectId()

I have an existing MongoDB collection which is basically looks something like: users: [ { "_id": ObjectId("56a6f714a2c56f1c3b0f17f1"), "name": "Daniel", "phones" : [ { "_id": ObjectId(""56a78dd1879c40ea63822141"), …
afterxleep
  • 622
  • 1
  • 5
  • 17
3
votes
2 answers

Different types of Function in Object_ID

When creating functions, I tend to preface the creation with an existence check IF Object_ID(N'myfunc', N'IF') IS NOT NULL DROP FUNCTION myfunc GO CREATE FUNCTION myfunc... There are several types of object_id to be checked for functions : FN =…
Kenny
  • 1,902
  • 6
  • 32
  • 61
3
votes
1 answer

MongoDB ObjectID type on front-end

I am having trouble finding information online as how to use Mongo ObjectID instances on the front-end. I can't answer these questions: (1) is it safe to serialize/deserialize ObjectID objects to/from JSON? (2) How can I require the ObjectID module…
Alexander Mills
  • 90,741
  • 139
  • 482
  • 817
3
votes
0 answers

TypeError: Cannot read property 'ObjectID' of undefined

My code is as follows,Use nodejs to upload files on the web page perform file upload , server error。 I'm trying to stream file uploads directly to Mongo. It seems like gridform (https://github.com/aheckmann/gridform) is a great solution for…
hz_xwh
  • 31
  • 3
3
votes
1 answer

How to create ObjectId in Mongoose 4.0.x from Hex string?

mongoose.mongo.Types.ObjectId does not have fromString or fromHexString functions. It seems that new mongoose.mongo.Types.ObjectId(hexString) does not create an object id either. var id = new…
swogger
  • 1,079
  • 14
  • 30
3
votes
1 answer

Is there a theoretical limit to the number of objects Ruby can store?

At least up to a little more than 20_000_000, the object_ids of numbers are 2 times the number + 1: 1454.object_id # => 2909 When calling the object_id on large numbers, this format is not kept. It seems like there is a built in limit to the number…
Richard Hamilton
  • 25,478
  • 10
  • 60
  • 87
3
votes
1 answer

How to find a mongoId in an array of mongoIds outside a db call

I'm aware its possible to find this out via a db call, but out of curiosity for instance in node If I had an array of mongoose document ids. How could I emulate an indexOf function against that array to determine if another mongoId is in it? I only…
Austin Davis
  • 3,516
  • 10
  • 27
  • 47
3
votes
1 answer

How to query by ObjectId in Motor in tornado

I am trying to use tornado, and my use case is to query by the object ID. I have seen examples and ref's to query by anything else, but the ObjectID. since it is unique, I want to use it instead to query. Any suggestions how to use the ObjectId for…
neoeahit
  • 1,689
  • 2
  • 21
  • 35
3
votes
1 answer

Why is the _id for a mongo document STRING but not ObjectID by default

The document of Meteor says that it use STRING as the _id by default. What's the meaning behind it? What if I write a script to import a huge csv file but would like to give each of them a random string, what can I do?
waitingkuo
  • 89,478
  • 28
  • 112
  • 118
3
votes
3 answers

Generating a new Mongo object id for each document in a collection?

How do you go about creating a unique object id for each document in a mass update? I've tried, db.foo.update({ objectId: null }, { $set: { objectId: new ObjectId() }}, { multi: true }) But that gives me the same object id for each document.
James McMahon
  • 48,506
  • 64
  • 207
  • 283
3
votes
1 answer

Cannot use object of type MongoId as array when trying to extract Mongo ID hex code

I'm trying to extract the hex code of a Mongo ID ObjectId using PHP. This error comes up whenever I try to extract the ID number and store it in another variable. var_dumping the contents of a document fetched by a Mongo query gives something like…
A. Duff
  • 4,097
  • 7
  • 38
  • 69