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

ObjectRepository object id #102

Closed
dustin-auby opened this issue Aug 16, 2018 · 6 comments
Closed

ObjectRepository object id #102

dustin-auby opened this issue Aug 16, 2018 · 6 comments

Comments

@dustin-auby
Copy link

Hi, when using an ObjectRepository with a mapped object how can i get the NitriteId for an object. i have checked the documentation and can only find an example of getting the id from a Document not a Object.

@anidotnet
Copy link
Contributor

Here you go - NitriteIdAsIdTest

@anidotnet anidotnet self-assigned this Aug 16, 2018
@anidotnet anidotnet added this to To Do in Nitrite Development via automation Aug 16, 2018
@anidotnet anidotnet added this to the 3.1.0 milestone Aug 16, 2018
@anidotnet anidotnet reopened this Aug 16, 2018
Nitrite Development automation moved this from To Do to In progress Aug 16, 2018
@dustin-auby
Copy link
Author

Thanks i will do that. while i was playing around i tried adding a variable called _id to the object to test what happens and it mapped the id correctly . would this be a bad idea to use ?

@anidotnet
Copy link
Contributor

I'll suggest not to depend on database internals. If some day the default id key is changed to something else say $id, then your code will break after upgrading nitrite verson.

@dustin-auby
Copy link
Author

Ok thanks, will the method you are using not cause a performance issue though as you are generating an id twice ? i could be inserting thousands of rows at times.

@anidotnet
Copy link
Contributor

I am not generating id twice, just reusing what is there in collection. There would not be any performance impact as far as I think, though you can confirm it by creating a stress test yourself.

@dustin-auby
Copy link
Author

there was a slight drop but its negligible when inserting 10000 records it took 14.1 seconds and with the addition it took 15.5 seconds. these were quite big reccords

Nitrite Development automation moved this from In progress to Done Aug 21, 2018
anidotnet added a commit that referenced this issue Aug 21, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

No branches or pull requests

2 participants