[SERVER-14402] Make ObjectID optional on new records Created: 01/Jul/14  Updated: 09/Jul/16  Resolved: 08/Jul/14

Status: Closed
Project: Core Server
Component/s: None
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Minor - P4
Reporter: Trausti Thor Johannsson Assignee: Andy Schwerin
Resolution: Done Votes: 1
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Participants:

 Description   

Converting objectid to and from strings takes time, is error prone and requires a major amount of work, on every call and query to the database.

It would be fantastic if you could flip a switch, and instead of getting auto generated ObjectID, getting an ObjectID string instead.

This would also make it much simpler to convert data from any database, like couchdb and mysql into Mongo.



 Comments   
Comment by Thomas Rueckstiess [ 08/Jul/14 ]

Hi traustitj,

As Andy explained above, this is not something that the server should do. If you don't want the _id values to be of type ObjectId, your application can just generate string _id values on document creation. If you're concerned about uniqueness of such strings, you could even use the ObjectId class of your driver to generate a unique id, then convert that to a string and use that value as _id.

Regards, Thomas

Comment by Andy Schwerin [ 01/Jul/14 ]

The _id field is typically generated by the client driver, rather than by the database server. In either event, if the application supplies its own _id value, that is used preferentially. Perhaps in this case it would be more straightforward to generate your own _id field values, which could be strings if you prefer.

Generated at Thu Feb 08 03:34:44 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.