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

Simple Table.where not working as expected #1960

Open
tacman opened this issue Apr 16, 2024 · 0 comments
Open

Simple Table.where not working as expected #1960

tacman opened this issue Apr 16, 2024 · 0 comments

Comments

@tacman
Copy link

tacman commented Apr 16, 2024

db.version(3).stores({
    savedTable: "id,name,owned",
    productTable: "++id,price,brand,category"
});

        let table = db.table('savedTable');
        table = table.where({owned: true}).toArray().then(rows => console.log(rows)).catch(e => console.error(e));

I'm trying to simply filter by owned: true. Actually, I have a more complicated query, and want to use where. I have something working with filter, but it seems like where more appropriate.

            this.filter = {owned: true};
            table = table.filter(row => {

            let okay = true;
            for (const [key, value] of Object.entries(this.filter)) {
                okay = okay && (row[key] === value);
            }
            return okay;
        });

what am I misunderstanding in where()?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant