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

MongoDB Storage Capabilities #57

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Conversation

Yohan460
Copy link

@Yohan460 Yohan460 commented Oct 4, 2022

Enabling mongoDB storage support and integrating it into the cli startup capabilities

Note: The feature TODOs are not mission critical to the daily operation

Happy to support as necessary going forward 😀

@jessepeterson
Copy link
Member

I haven't had a chance to review this yet, not sure when I'll get time. But one thing I saw just glancing at the PR was that in a few places you're using "UDID" as a key or column name or something. I'd recommend against that and just using "id" or "enrollment_id" instead as NanoMDM explicitly "collapses" things like UDID (and more complex scenarios) into just "id." I do see you're using r.ID in places which is good, so this is just a "column" naming thing (does MongoDB use "columns" even? lol). Anyway, there's that until I get some more time. :)

@Yohan460
Copy link
Author

Hey @jessepeterson, The udid field in Mongo is used as a storage for the nanomdm ID field. Essentially it works as a rename. The reason I'm doing this is becuase the internal immutable document ID is stored under the _id field and I don't really like having id and _id being so similar. Hence the rename to udid.

I did read over the ID Normalization and that's handled in this situation.

As for your comment about columns. Mongo uses a document based implementation where essentially you can dump any data you want into a database collection as long as it satisfies the defined indexes of the collection

Here is an example

_, err = storage.CheckinCollection.Indexes().CreateOne(context.TODO(), mongo.IndexModel{
Keys: bson.M{
"udid": 1,
},
Options: options.Index().SetUnique(true),
})

This entails that the CheckIn Collection must have unique MDM Request IDs. Since the r.ID is assigned to the udid field

FWIW I'm happy to take on any bugs this causes in the event you want to defer the whole thing to us

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.

3 participants