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

How to check that mongo ObjectID is valid in python?

I want to verify that the objectID is a valid mongoID string. Currently I have: import bson try: bson.objectid.ObjectId(id) except: pass # do something I wanted to make my exception more specific, and it looks like there is a solution, but…
Salvador Dali
  • 214,103
  • 147
  • 703
  • 753
12
votes
4 answers

How to randomly generate objectid in node js

I need to randomly generate objectid in node js.Is there is any way to create.
user1705980
  • 183
  • 1
  • 1
  • 9
11
votes
1 answer

Migration of Small Parse IDs to normal MongoDB's ObjectIDs

I am using Parse Dashboard for User Management of my iOS Application.Also, I am using external APIs which are using MongoDB database. The issue currently I am facing is the User created from Parse Dashboard is having small id instead of MongoDB's…
Aditya Raval
  • 590
  • 4
  • 20
10
votes
1 answer

Mongodb get the 3-byte counter from an ObjectId

How/Can I get the 3-byte counter, starting with a random value part from a mongodb ObjectId? I have an ObjectId like this: ObjectId("507f1f77bcf86cd799439011") According to mongodb documentation: Description ObjectId() Returns a new ObjectId…
kailniris
  • 8,856
  • 2
  • 17
  • 24
9
votes
3 answers

mongoose query: find an object by id in an array

How could I find an image by id in this Schema. I have the id of the User and the id of the image I am looking for. What would be the best way to do this and do all images in this case have different ids or could they have the same id because they…
user3888540
  • 105
  • 1
  • 1
  • 3
9
votes
2 answers

mgo convert bson.objectId to string(hex) in html template

I know this problem maybe duplicate to this one. But it hasn't get a satisfied answer till now. And I really want to draw some attention to get a solution as soon as possible. So I beg you not to close this issue unless you have the solution and…
armnotstrong
  • 8,605
  • 16
  • 65
  • 130
9
votes
1 answer

Core Data Object IDs vs Permanent Object ID

This question might look like it's been asked many times before, but I'm not sure I've aggregated the answer correctly. So here goes. ObjectIDs are described by Apple (WWDC 2012 Session 214) as context-safe, thread-safe. So I spent some time…
8
votes
1 answer

Finding a MongoDB document by ObjectId with Mongoose

I am trying to update a document in MongoDB by finding it by the ObjectId. The work flow is as follows (this is for a blog). Create a new post in MongoDB by passing a title and body. The ObjectId is automatically created. Go to edit the post. It…
David Yeiser
  • 1,438
  • 5
  • 22
  • 33
8
votes
1 answer

How to get eclipse debug id of an object?

Is it somehow possible to get the object id programmatically, which is seen in the debug tooltip in eclipse?
Skip
  • 6,240
  • 11
  • 67
  • 117
7
votes
2 answers

How to insert a custom ObjectId with collection.insert() in mongoose

I'm trying to batch insert several users into the database. For testing purposes I would like to set a specific ObjectId to each individual document. For some reason I can't insert a valid ObjectId. For example: var users = [ { …
stephan
  • 655
  • 1
  • 7
  • 11
7
votes
1 answer

Sub-query in MongoDB

I have two collections in MongoDB, one with users and one with actions. Users look roughly like: {_id: ObjectId("xxxxx"), country: "UK",...} and actions like {_id: ObjectId("yyyyy"), createdAt: ISODate(), user: ObjectId("xxxxx"),...} I am trying…
WhatAmIDoing
  • 198
  • 1
  • 1
  • 6
7
votes
1 answer

Mongo: how to find by ObjectId that is stored in a subarray?

I have a collection with records like this: { "_id" : ObjectId("50ae3bdb50b3d6f01400027a"), "admins": [ObjectId("50ae3bdb50b3d6f014000279"), ObjectId("50ae3bdb50b3d6f01400027e")] } I would like to search by the the 'admin'…
Tomas Randus
  • 2,127
  • 4
  • 29
  • 38
6
votes
1 answer

String to Primitive.ObjectID

I am using mongo-driver from go.mongodb.org/mongo-driver. I already converted primitive.ObjectID to string Using this link Primitive.ObjectID to string Now i need to convert string to primitive.ObjectID
Faizal Ahamed
  • 118
  • 1
  • 4
  • 7
6
votes
1 answer

Is it possible to create ObjectId in Mongo shell?

I'm updating a document with an array of embedded documents, directly in Mongo shell. I would like each of these sub-docs to have an _id field, but these are not created automatically as they are for top-level documents. Is there a way to simply…
Antoine
  • 5,055
  • 11
  • 54
  • 82
6
votes
2 answers

Shorten ObjectId in node.js and mongoose

my URLs look like this at the moment: http://www.sitename.com/watch?companyId=507f1f77bcf86cd799439011&employeeId=507f191e810c19729de860ea&someOtherId=..... So, as you can see, it gets pretty long, pretty fast. I was thinking about shortening these…
Drag0
  • 8,438
  • 9
  • 40
  • 52
1
2
3
32 33