mbdavid / LiteDB

LiteDB - A .NET NoSQL Document Store in a single data file
http://www.litedb.org
MIT License
8.51k stars 1.24k forks source link

UPDATE SQL Syntax #1612

Open sanjeevbaral opened 4 years ago

sanjeevbaral commented 4 years ago

Hi

I had submitted a question about a week ago but did not get any response, so trying to ask differently in case I was not clear in that post.

I am trying to let power users of my application write SQL like syntax to update a collection. I can use the UPDATE statement to update any field in the root document easily. However, I have not figured out SQL to update a field in the child documents. I have a patients collection with Patient documents; each Patient has a Tumor field which is an array of Tumor documents. Is it possible to update one or more fields in Tumor documents using SQL?

lbnascimento commented 4 years ago

@sanjeevbaral Sorry about the delay. LiteDB SQL syntax does not currently support updating fields not present in the root document (this is not in the documentation, I'll add it). You would have to store the document you're trying to update, manually change sub-fields and then call update using this new document.

sanjeevbaral commented 4 years ago

Thank you! Since I want the end-user to be able to run the update script I decided to change the document structure so that there are no child documents anymore. This causes duplication of data but that's okay. This is only a smallish temporary database where users import documents and do cleanups. Any plan to support updates on child documents in the future?