appy-one / acebase

A fast, low memory, transactional, index & query enabled NoSQL database engine and server for node.js and browser with realtime data change notifications
MIT License
488 stars 27 forks source link

Allow read-only access to the database #88

Closed bernatesquirol closed 2 years ago

bernatesquirol commented 2 years ago

It would be great to be able to reference as a read-only an already created storage-database. A use case is using acebase as a "cache" in AWS Lambda, where the writing of files is forbidden, but the reading is allowed.

In short, being able to change this r+->r from function openDatabaseFile in storage-acebase.js https://github.com/appy-one/acebase/blob/24ca5f2038083a6c8f8fab6d29114a1c082a16d3/src/storage-acebase.js#L764

appy-one commented 2 years ago

I just published v1.16.0 which supports this, simply pass readOnly: true in the storage settings:

const db = new AceBase('mydb', { storage: { readOnly: true } });

Let me know if it works!