Skip to content

Autogenerate MongoDB ObjectIds #431

@rshmhrj

Description

@rshmhrj

Problem
Currently using Randomness to help generate GUIDS in the UUID format for unit tests / test data. Would like to extend it to autogenerate ObjectIds (similar to the output here). Tried creating a new scheme within String settings to create a format that looks like an ObjectID:

image

  • min / max both set to 24
  • quotation marks set to "
  • capitalization set to lower
  • symbol sets only has hexadecimal checked

This generates an okay looking String but it doesn't get accepted as a valid ObjectId when inserting into Mongo.

Suggested solution
Create 6th section for ObjectIds

Alternative solutions
Add as an option within the UUID section

Additional context
Would also be nice to have the following options:

  • quotes on or off
  • single or double quotes
  • prefix with ObjectId( and postfix with )

Metadata

Metadata

Assignees

Labels

featureNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions