Oh, sorry, I got my reply backwards! I meant “definitely OK”, not “definitely must be a singleton”. So:
It’s fine to have multiple Database instances for the same physical database file. This can improve performance if you’re using the database heavily on multiple threads, for instance.
Opening the same database file in multiple processes is OK; however, database- and document-change notifications are not delivered cross-process, so if another process changes the database you will not be notified, and LiveQueries will not update.
Am I glad I had a question on your answer!
So that also means (just to clarify) that even with multiple instances (of the same db) within the same app, LiveQueries and document change do indeed update.
Yes?
Thanks.
ps. If so, I guess it would also work for multiple instances of the same document as well?
Having multiple instances of a document can be useful, especially with multiple threads. Just be aware that MVCC (multi-version concurrency control) applies to each instance. So if you create two instances of the same document, then make changes in each one and save, the second one you save will run into a conflict with the first.