Lokijs.org
A fast, in-memory document-oriented datastore for node.js, browser and cordova.
Use cases:
- To achieve database like feature on a limited resources (Raspberry Pi like) device.
- To create secure applications without running an server.
- To persist data and reuse it, for rich feature applications at client side.
- ..
The list can go on up 100 points.
Big loss in usability?
No.
Because it fulfills the purpose for which it is introduced. (In memory datastore)
Is there a way to hard-code a LokiJS database?
Yes.
Create a yourExampleDB.json or yourExampleDB.db file and insert data in a following manner.
{
"filename": "yourExampleDB.db",
"collections": [{
"name": "entries",
"data": [{
"id": 17948697,
"properties": { ... },
"meta": {
"revision": 0,
"created": 1524651771378,
"version": 0
},
"$loki": 1
}, {
"id": 17948705,
"properties": { ... },
"meta": {
"revision": 0,
"created": 1524651771378,
"version": 0
},
"$loki": 2
},
...
...
...
{
"id": 11699810,
"properties": { ... },
"meta": {
"revision": 0,
"created": 1524651771402,
"version": 0
},
"$loki": 11299
}],
"idIndex": [1, 2, ... 11298, 11299],
"binaryIndices": {},
"constraints": null,
"uniqueNames": [],
"transforms": {},
"objType": "entries",
"dirty": false,
"cachedIndex": null,
"cachedBinaryIndex": null,
"cachedData": null,
"adaptiveBinaryIndices": true,
"transactional": false,
"cloneObjects": false,
"cloneMethod": "parse-stringify",
"asyncListeners": false,
"disableMeta": false,
"disableChangesApi": true,
"disableDeltaChangesApi": true,
"autoupdate": false,
"serializableIndices": true,
"ttl": null,
"maxId": 11299,
"DynamicViews": [],
"events": {
"insert": [null],
"update": [null],
"pre-insert": [],
"pre-update": [],
"close": [],
"flushbuffer": [],
"error": [],
"delete": [null],
"warning": [null]
},
"changes": []
}, {
"name": "messages",
"data": [{
"txt": "I will only insert into this collection during databaseInitialize.",
"meta": {
"revision": 0,
"created": 1524651771378,
"version": 0
},
"$loki": 1
}],
"idIndex": [1],
"binaryIndices": {},
"constraints": null,
"uniqueNames": [],
"transforms": {},
"objType": "messages",
"dirty": false,
"cachedIndex": null,
"cachedBinaryIndex": null,
"cachedData": null,
"adaptiveBinaryIndices": true,
"transactional": false,
"cloneObjects": false,
"cloneMethod": "parse-stringify",
"asyncListeners": false,
"disableMeta": false,
"disableChangesApi": true,
"disableDeltaChangesApi": true,
"autoupdate": false,
"serializableIndices": true,
"ttl": null,
"maxId": 1,
"DynamicViews": [],
"events": {
"insert": [null],
"update": [null],
"pre-insert": [],
"pre-update": [],
"close": [],
"flushbuffer": [],
"error": [],
"delete": [null],
"warning": [null]
},
"changes": []
}],
"databaseVersion": 1.5,
"engineVersion": 1.5,
"autosave": false,
"autosaveInterval": 5000,
"autosaveHandle": null,
"throttledSaves": true,
"options": {
"serializationMethod": "normal",
"destructureDelimiter": "$<\n"
},
"persistenceMethod": "fs",
"persistenceAdapter": null,
"verbose": false,
"events": {
"init": [null],
"loaded": [],
"flushChanges": [],
"close": [],
"changes": [],
"warning": []
},
"ENV": "NODEJS"
}
It's a valid example copy of lokijs db.
something like PHPMyAdmin to inspect/add/delete?
No.
Or do I have do add all the data via JavaScript?
Yes
Steps to follow
- Require lokijs module.
- Create a db.
- Create a collection.
- Insert your data.
- Persist it (Manual/Auto)
Hope it helps.