some questions on the article using-litedb-in-an-asp-net-core-api #423
-
First and formost Thank you for the great article - very concise and a grat example to get going with. The questions are:
or does this have implications when using a singleton instance to serve all web based requests (or other reasons to avoid this pattern)?
Any thoughts on where, when and how to create the indexes (it seems a very different pattern to SQL where the indexes are created before adding data)? Thanks again for the article, example repo and thanks for your thoughts and 1 samll suggestionI have been reading the documentation about autoID, and I think some notes would go well in the article and or a comment or 2 in the code. If the int Id is default(0), then an auto Id is generated (and likewise for Guid types having a Guid.Empty value). When inserting any other int value, the database will insert that Id (or the operation fails if a duplicate). Importantly and unlike most SQL databases, the next identiy is NOT persisted in the database, so if a record is inserted, assigned an autoId of 3, then deleted, then a completely different record is inserted it may also be given an id of 3 (technically only if the datafile is closed between delete and insert operation, but shutdowns and crashes definately happen). For this reason, it may not be the best choice for a truly restful API. Options then become either using a LiteDb object Id, Guid or implementing some kind of persistance storage yourself and autoincrementing accordingly. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Thank you very much for the comment! I am sorry for the delay but i am currently on a paternal leave and it will be some time until i return! I will extend my answer a later time, but here is a quick one - its all from my mobile so i hope i remember the article and sample repo and my comments are correct!
The suggestion is a very nice one and super useful, thank you 😊 |
Beta Was this translation helpful? Give feedback.
Thank you very much for the comment!
I am sorry for the delay but i am currently on a paternal leave and it will be some time until i return!
I will extend my answer a later time, but here is a quick one - its all from my mobile so i hope i remember the article and sample repo and my comments are correct!
LiteDatabase
every time, like a transient approach. Is this correct? Please include a bigger sample if i didn't get it!