Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Verbatim ObjectId() #40

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

nurih
Copy link

@nurih nurih commented Jun 12, 2023

With the alias $oid it is not possible to express a constant ObjectId value, since the framework would ignore the value, even if a template included the ObjectId value.

{"$objectid": "000000001111111122222222"}

// would result in a random new ObjectId

{"$oid": "648750fb87f87cb95eeccf6c"} // new one each time

This PR introduces the optional value to allow templates to include verbatim ObjectId values.

New behavior triggered if optional value is supplied:

{"_id": {"$objectid": {"value": "000000001111111122222222"}}
// Result would be the constant
{"_id": {"$oid": "000000001111111122222222"}}

Existing behavior remains as is:

{"_id": "$objectid"}

The above results in a new ObjectId generated each time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant