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

mongodb part of objectid most likely to be unique

In my app I'm letting mongo generate order id's via its ObjectId method. But in user testing we've had some concerns that the order id's are humanly 'intimidating', i.e. if you need to discuss your order with someone over the telephone, reading out…
Petrov
  • 4,200
  • 6
  • 40
  • 61
6
votes
2 answers

GORM get/find resource by ID using MongoDB in Grails

Grails makes it easy to get a domain object by ID (handy for building a REST API). A controller to retrieve a resource can be as simple as: MetricController.groovy import grails.converters.JSON class MetricController { def index() { def…
Dem Pilafian
  • 5,625
  • 6
  • 39
  • 67
6
votes
1 answer

Why object_id persists on windows while not on linux?

This program class ObjectGarden class << self.clone puts self.object_id end end puts ObjectGarden.clone.object_id When run on Linux (have tested on RHEL) generates distinct object_ids across multiple runs as I had expected.…
saihgala
  • 5,724
  • 3
  • 34
  • 31
5
votes
1 answer

Why ObjectID is not defined in Mangodb?

I try to query my MongoDB by finding particular "_id" but new ObjectID does not do the trick. And I try to create a variable hold a random ObjectID by "var obj = new ObjectID()" which does not work as well. Then I check my MongoDB version and it is…
crazymind
  • 169
  • 2
  • 11
5
votes
2 answers

Loopback 4/MongoDB - Foreign key not converted to ObjectID

I am trying to set up an hasMany relation using a Mongo database. I have followed the guide to create an hasMany relation in the loopback 4 documentation (https://loopback.io/doc/en/lb4/HasMany-relation.html) and tryied to set differents properties…
FabienCH
  • 51
  • 5
5
votes
1 answer

Mongoose: cast to array failed for value "[ 5ac5cfb41fca8a22f519cb22 ]"

I am trying to insert a round in a existing game, which gives me the following error: Game validation failed: rounds.1.questions: Cast to Array failed for value "[ 5ac5cfb41fca8a22f519cb22 ]" at path "questions" Schema's: const roundSchema =…
5
votes
1 answer

Generating ObjectID's in Aggregate

I have a collection called people (see below) that contains their personal details and skills. From that collection I want to create a new collection (which regularly updates) with the total amount of occurences for a certain skill filled with an…
5
votes
1 answer

meteor 0.5.7: how to handle/use Meteor.Collection.ObjectID?

I have updated my meteor yesterday and tried using the new Meteor.Collection.ObjectID. But since with no success. First i updated my collections in this way: myCollection = new Meteor.Collection('mycollection', {idGeneration: 'MONGO'} Now, normal…
net.user
  • 821
  • 2
  • 11
  • 22
4
votes
1 answer

Get _id without ObjectId from MongoDB

I am trying to get the _id from a collection without getting the ObjectId part. When I try and query it this way: db.collection.aggregate([ {'$unwind': '$_id'}, { '$project': { '_id': '$_id' } } ]) This…
nb_nb_nb
  • 1,243
  • 11
  • 36
4
votes
0 answers

MongoDB and TypeScript: Decouple a domain entity's id type from MongoDB's ObjectID

Inside my MongoDB repositories, entities have an _id: ObjectID type to be handled properly. However, I would like my domain entities to have a simple id: string attribute to avoid any dependencies on any database or framework. The solution I came up…
C. Doe
  • 1,180
  • 8
  • 12
4
votes
3 answers

Swagger (Swashbuckle for C#) shows Mongo ObjectId as several fields instead of single string

I have controller method with ObjectId params: [ProducesResponseType(200, Type = typeof(Test))] [HttpGet] [Route("{id}")] public IActionResult Get(ObjectId id) {... For this API method swagger generates a form with both of complex ObjectId model…
razon
  • 3,882
  • 2
  • 33
  • 46
4
votes
1 answer

NodeJS & MongoDB - Get Objects based on array of ids

I am having trouble returning getting the Objects in a collection based on an array of ObjectIds. I have a collection of 10 items. In an iOS app, I am passing up an array of ObjectIds that user has saved as favorites to return just those two in a…
Marc Blazyk
  • 87
  • 1
  • 9
4
votes
0 answers

Cast to number failed for value "XXX" at path "_id" for model "users" Mongoose Mongodb

I am having problems populating across 2 different models. User and Player. Each has a ObjectId stored for each other. My error occurs when I try to find the following populate from the User model. User.find().populate('player_id') Data of Users…
Jamie Hutber
  • 26,790
  • 46
  • 179
  • 291
4
votes
2 answers

Mongoose - Generate ObjectID for each object before saving document

I want generate an ObjectID for each Object present inside my array. The thing is I'm getting the products with a .forEach statement from another server and push them inside my array without a Schema that generates an ObjectID.... Product…
4
votes
2 answers

How to add binary data with objectId to mongoDB?

I need to insert a document into a collection, which has an ObjectId and a BinData value. Therefore I don't know how to insert it. With this code I get the error TypeError: Cannot read property 'ObjectId' of undefined. server/fixtures.js var…
user3142695
  • 15,844
  • 47
  • 176
  • 332
1 2
3
32 33