我刚刚开始使用LokiJS,我有一个基本问题,我无法解决这个问题:
有没有办法对LokiJS数据库进行硬编码?或者我是否通过Javascript添加所有数据?
对我来说,像PHPMyAdmin这样的东西来检查/添加/删除数据库中的实际数据似乎是必要的,但到目前为止我还没有找到任何东西,用LokiJS数据库来做这件事。这不是可用性的重大损失吗?
答案 0 :(得分:0)
Lokijs.org
针对node.js,browser和cordova的快速,内存中面向文档的数据存储区。
用例:
该列表可以上升100点。
可用性大失失?
没有
因为它符合引入它的目的。 (在内存数据存储区中)
有没有办法对LokiJS数据库进行硬编码?
是
创建yourExampleDB.json或yourExampleDB.db文件,并按以下方式插入数据。
{
"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"
}
这是lokijs db的有效示例副本。
类似于PHPMyAdmin来检查/添加/删除?
没有
或者我是否通过JavaScript添加所有数据?
是
要遵循的步骤
希望它有所帮助。