I'm just starting off with LokiJS and I have one fundamental question I can't wrap my head around:
Is there a way to hardcode a LokiJS database? Or do I have do add all the data via Javascript?
It seems necessary to me, to have something like PHPMyAdmin to inspect/add/delete the actual data in the database, but I have found nothing so far, to do this with a LokiJS database. Isn't this a big loss in usability?
Lokijs.org
A fast, in-memory document-oriented datastore for node.js, browser and cordova.
Use cases:
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
Hope it helps.