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

ObjectId vs String _id consistency #758

Open
ansoncfit opened this issue Nov 14, 2021 · 1 comment · May be fixed by #837
Open

ObjectId vs String _id consistency #758

ansoncfit opened this issue Nov 14, 2021 · 1 comment · May be fixed by #837
Labels
p1 Priority level 1: high, but not the top t1 Time level 1: think days

Comments

@ansoncfit
Copy link
Member

Eventually we'd like our database _id (and nonce) values to be ObjectIds, rather than Strings as was our longstanding practice, because we expect indexing and lookup to be more efficient.

As we incrementally make this transition, we should test to make sure that within a given collection, values are one type or the other.

We should also add more comments to specify which we expect in certain places, and consider fallback code in functions that may need to handle both. For example, if no records are found in the line here, we could try a lookup by the String _id (instead of the ObjectId) before returning?

@abyrd
Copy link
Member

abyrd commented Nov 14, 2021

Most importantly we want to work toward a state where they are of consistent type across the entire database - not necessarily all ObjectIds, but either all ObjectIds or all Strings. There may be big advantages to ObjectId, I'm not sure and will have to research that. But most databases should be able to index String IDs reasonably efficiently, especially at the scale of this application.

I am not sure this is a case where we want to transition incrementally - it will be much easier to reason about if they are all the same type everywhere. I tend to see type fallbacks as another thing to go wrong.

One problem we've encountered is that older object IDs may contain dashes or other non-hex digits. These can be stripped out to create new ObjectIds but we must update the names of any corresponding objects on S3.

@trevorgerhardt trevorgerhardt added p1 Priority level 1: high, but not the top t1 Time level 1: think days labels Nov 24, 2021
@ansoncfit ansoncfit linked a pull request Nov 10, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p1 Priority level 1: high, but not the top t1 Time level 1: think days
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants