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
2 answers

Why is this MongoDB ObjectID infinite in Google spreadsheet?

Type the MongoDB ObjectID 52489e882967060200000283 into a cell in a Google spreadsheet and it's clobbered by ∞. What gives?
hurrymaplelad
  • 26,645
  • 10
  • 56
  • 76
3
votes
1 answer

MongoDb Range Query on ObjectId

I had like to know if somebody knows if it is possible to query the _id field with a query like this : {$lte : ObjectId(....) , $gte : ObjectId(...) , instead of {$in : [ObjectId( )...lots of ObjectId.....]} and if there is a gain in performance…
3
votes
1 answer

Python id(obj) changes ad-hoc

Here's an excerpt from Python's docs re id() build-in function: == id(object) == Return the “identity” of an object. This is an integer (or long integer) which is guaranteed to be unique and constant for this object during its lifetime. Two objects…
Jonathan Livni
  • 101,334
  • 104
  • 266
  • 359
3
votes
1 answer

Generating Mongo ObjectId (_id) with custom time?

I am porting over a table of articles from MySQL to Mongo DB. I understand that the _id field generated by Mongo has the time of creation somehow in there and can be extracted or you can query against it. Because of this, I want to use it to have my…
Glitches
  • 742
  • 2
  • 8
  • 18
3
votes
2 answers

Hack ObjectId to indicate the object type

I want to hack ObjectId by manipulating the machineId like this: UserId XXXXXXXX XXXX01 XXXX XXXXXX OrderId XXXXXXXX XXXX02 XXXX XXXXXX CardId XXXXXXXX XXXX03 …
BigFatSea
  • 473
  • 1
  • 6
  • 13
3
votes
1 answer

Errors from `ObjectSpace._id2ref`

What is the difference between the following two kinds of errors that ObjectSpace._id2ref returns? 0x... is recycled object (RangeError) 0x... is not id value (RangeError)
sawa
  • 165,429
  • 45
  • 277
  • 381
2
votes
3 answers

Class constructor ObjectId cannot be invoked without 'new' in mongoose

When I send data from frontend to backend via API request I got this error: Class constructor ObjectId can not be invoked without 'new' in mongoose, I tried to convert into string and also into int but it didn't work.....
2
votes
2 answers

I can't delete a data from mongoDb ObjectId class constructor error

I have written a express index.js to simple crud operation in mongodb. the item is the params I can console.log as mongodb Id however, ObjectId buildin function giving me a an class constructor error that it cannot inboked without 'new'. const…
2
votes
1 answer

Type Error when using ObjectId class in MongoDB Node JS Rest API

I am creating the rest APIs using Next Js and MongoDB, with Type Script checking. When creating one of the routes to fetch the post by Id, I get the following error: (property) NextApiRequest.query: Partial<{ [key: string]: string |…
program_bumble_bee
  • 439
  • 2
  • 25
  • 57
2
votes
1 answer

how to get the value of mongodb ObjectId?

I am new to mongodb and I am trying to get a Documment from the database and populate some fields this is an example : var profile = await this.profileModel .findById(id) .populate({ path: 'posts', populate: { path:…
2
votes
0 answers

MongoDB NestJS API dies if a @Prop is set to ObjectId

So, when i set a @Prop() to ObjectId, the api wont start, but if i set it a string it loads up just fine. Can you help me? Thanks! Heres the error: Schema: import { Prop, Schema, SchemaFactory } from "@nestjs/mongoose"; import { Document, ObjectId…
Alms
  • 31
  • 10
2
votes
1 answer

cannot convert ObjectId to String in MongoDb forEach function

I'm trying to process data in mongodb between different collection using cursor.forEach. The tool is DataGrip 2021.3.1 and the MongoDB server version is 4.4.9. The statement is like below: db.reward.find({type: "Test"}).forEach( function (p) { …
Richard
  • 148
  • 6
2
votes
1 answer

Why does adding mutable produce different hash values?

I have a simple struct like this with no custom == or hash() methods: struct IntroductionMessage message::String end When I call hash() both return the same value: say_hello_introduction = IntroductionMessage("Hello…
user19242326
2
votes
3 answers

How to convert from new ObjectId() to string in Mongodb?

Below is my code to create a review and add it to my reviews array of restaurants collections, I am also displaying this review after adding it to the collection. const res = require('./restaurants'); async create (restaurantId, title, reviewer,…
Swayam Shah
  • 200
  • 1
  • 12
2
votes
3 answers

How do I display only part of the array after findOne in MongoDB?

Restaurants is a collection and has objects like below: { _id: new ObjectId("61723c7378b6d3a5a02d908e"), name: 'The Blue Hotel', location: 'Noon city, New York', phoneNumber: '122-536-7890', website: 'http://www.bluehotel.com', …
Swayam Shah
  • 200
  • 1
  • 12