ujjwalguptaofficial / JsStore

Simplifying IndexedDB with SQL like syntax and promises
http://jsstore.net/
MIT License
858 stars 110 forks source link

Feature: Where on nested Object #282

Closed ujjwalguptaofficial closed 2 years ago

ujjwalguptaofficial commented 2 years ago

Discussed in https://github.com/ujjwalguptaofficial/JsStore/discussions/280

Originally posted by **fernandopiovezan1** August 9, 2022 Hi, I'm using JsStore and it's meeting my need perfectly. But a question arose after the implementation that I need to ask the question whether or not it is possible to do this type of consultation. I have a table with the following fields: ``` columns: { id: { primaryKey: true, autoIncrement: false, dataType: DATA_TYPE.Number, }, client: { dataType: DATA_TYPE.Object }, created_at: { dataType: DATA_TYPE.String, } } ``` The insertion I make for this table is as follows ``` { "client": { "id": 10, "name": "fernando", "number": 1234567 }, "created_at": "2022-08-09 00:00:00" } ``` I understand that the ideal thing is that the client object was a separate table so that it was possible to perform a join and with a direct where in the field of the related table. But when the base was created this was not implemented and now I need to perform a search directly in the name field of the client object, would this scenario be possible? Example of how I tried to create the query but in none of the scenarios it worked. ``` connection.select({ from: this.tableName, where: { // client.name: 'Fernando' // client: '{name: Fernando}' // client: '{name: "Fernando"}' // client: 'Fernando' client: 'name: Fernando' } }) ``` The commented lines are to exemplify what was tested I only used one line at a time to test
ujjwalguptaofficial commented 2 years ago

where on nested object won't be supported for now, as indexeddb does not support indexing on nested object.

But user who need it can use transaction to write their own filter logic and achieve the functioanlity.

https://jsstore.net/tutorial/transaction/

If need any help, feel free to comment.