-
Notifications
You must be signed in to change notification settings - Fork 26
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
Examples needed #176
Comments
In the meantime, I am trying to piece an example together that uses IndexedDB (based on examples and example in LokiJS): import Loki from '@lokidb/loki';
import LokidIndexedAdapter from '@lokidb/indexed-storage';
async initDB () {
const adapter = new LokidIndexedAdapter();
const options = {
env: 'BROWSER',
serializationMethod: 'normal'
};
const db = new Loki('test.db', options);
const persistenceOptions = {
adapter: adapter,
autosave: false,
autosaveInterval: 1000,
autoload: false,
throttledSaves: false,
persistenceMethod: 'indexed-storage'
};
await db.initializePersistence(persistenceOptions);
let entries = await this.db.getCollection('entries');
if (entries === null) {
entries = await this.db.addCollection('entries');
}
return db;
}
function mounted() {
try {
const db = await initDB();
const entries = db.getCollection('entries');
entries.insert({
id: 321,
phrase: 'hello world'
});
} catch (error) {
console.log(error);
}
} This results in an error:
ENV
|
Please have a look at the tests: |
@Viatorus thank you. Would you consider an initial example in the Read Me or as a new page in the docs? Also, can they be await/async or do they need to be promise.then()? |
I'm submitting a...
I looked in the following places for documentation on how to use LokiDB:
While the API is documented, there are no examples for anyone wanting to start with LokiDB. Maybe LokiJS could be a fall back, but it is not clear. I am not seeing a wiki either.
Can anyone indicate some examples that are suitable starting points?
The text was updated successfully, but these errors were encountered: