LokiJS Complex Queries

So I am using LokiJS as a local database, although I am having some trouble replicating a MySQL query to work…
The query I am trying to replicate is:

SELECT DISTINCT advertisers_approved.* FROM advertisers_approved INNER JOIN advertiser_categories_approved ON advertisers_approved.id = advertiser_categories_approved.advertiser_id INNER JOIN locations_approved ON advertisers_approved.id = locations_approved.advertiser_id INNER JOIN advertiser_times_approved ON advertisers_approved.id = advertiser_times_approved.advertiser_id WHERE ( advertiser_categories_approved.category_id = 12 OR advertiser_categories_approved.category_id = 11 ) AND ( locations_approved.region_id = 5 ) AND ( advertiser_times_approved.day_id = 3 AND '1055' >= advertiser_times_approved.open AND '1055' < advertiser_times_approved.close )

Could someone let me know if this is even possible to do in LokiJS, or will I have to do it manually, calling each item manually and filtering it manually?

It it is possible to replicate with LokiJS, could you give me some pointers?

Thanks.

I’m not familiar with LokiJS but after checking it out it seems like PouchDB …
They’re noSQL databases which store your data as objects (or documents). You will have to create your own javascript code that will filter the documents to give you the results you need.

With PouchDB I usually call the method allDocs to get all the documents in the database, then I filter them how I want to.

1 Like

I was using PouchDB, but it was way too slow for the amount of work I needed to do…
It was taking 20-40s per search. (Trying to keep it below 10-20).

Why don’t you use SQL Lite instead then? It supports queries and it’s a relational database.