ujjwalguptaofficial / JsStore

A complete IndexedDB wrapper with SQL like syntax.
http://jsstore.net/
MIT License
849 stars 109 forks source link

Can't use where with multiple multiEntry columns #319

Closed Jake-Thompson closed 1 year ago

Jake-Thompson commented 1 year ago

Title

Can't use where with multiple multiEntry columns

Description

query

connection.select({
    from: 'Items',
    order: {
        by: 'date_mod',
        type: 'desc'
    },
    where: {
        tags: 'has_tag',
        parents: 0
    }
})

current output []

expected output

[{
    "id": 60,
    "parents": [ 0 ],
    "childs": [],
    "name": "this item has a tag has_tag",
    "desc": "",
    "done": false,
    "date_created": null,
    "date_mod": "2023-03-25T23:34:46.117Z",
    "tags": [ "has_tag" ],
    "ext": {}
}]

table definition

{
    name: 'Items',
    columns: {
        id: {
            primaryKey: true,
            autoIncrement: true
        },
        parents: {
            dataType: 'array',
            default: [0],
            multiEntry:true
        },
        childs: {
            dataType: 'array',
            default: []
        },
        name: {
            notNull: true,
            dataType: 'string'
        },
        desc: {
            dataType: 'string',
            default: ''
        },
        done: {
            dataType: 'boolean',
            default: false
        },
        date_created: {
            dataType: 'date_time',
        },
        date_mod: {
            notNull: true,
            dataType: 'date_time'
        },
        tags: {
            dataType: 'array',
            default: [],
            multiEntry:true
        },
        ext: {
            dataType: 'object',
            default: {}
        }
    }
}
Jake-Thompson commented 1 year ago

I found a workaround which was suggested for when filtering on the same column https://github.com/ujjwalguptaofficial/JsStore/discussions/288

connection.select({
    from: 'Items',
    order: {
        by: 'date_mod',
        type: 'desc'
    },
    where: [
        {tags: 'has_tag'},
        {parents: 0}
    ]
})

works, however it's not as intuitive

ujjwalguptaofficial commented 1 year ago

gotcha, will take a look.

ujjwalguptaofficial commented 1 year ago

have fixed in v - 4.5.4. Please test and let me know.