mirror of
https://github.com/YuhangQ/InvoDB.git
synced 2025-01-24 21:50:58 +00:00
可索引 invo_id
This commit is contained in:
parent
a7f8ee9951
commit
7b550e4a71
3
.gitignore
vendored
3
.gitignore
vendored
@ -3,4 +3,5 @@ package-lock.json
|
||||
.vscode
|
||||
node_modules
|
||||
build
|
||||
yarn.lock
|
||||
yarn.lock
|
||||
.DS_Store
|
||||
|
19
demo/test.js
19
demo/test.js
@ -8,22 +8,15 @@ invodb.database('zzz.invodb')
|
||||
let col = invodb.colection('blog')
|
||||
if(!col.exist()) col.create();
|
||||
|
||||
for(let json of col.query({})) col.remove(json)
|
||||
// for(let json of col.query({})) col.remove(json)
|
||||
|
||||
let list = fs.readFileSync(__dirname + "/list.txt").toString().split("\n")
|
||||
for(let json of list) {
|
||||
col.insert(JSON.parse(json))
|
||||
}
|
||||
// let list = fs.readFileSync(__dirname + "/list.txt").toString().split("\n")
|
||||
// for(let json of list) {
|
||||
// col.insert(JSON.parse(json))
|
||||
// }
|
||||
|
||||
let result = col.query({
|
||||
id: {
|
||||
$gte: 1,
|
||||
$lte: 8,
|
||||
$or: [
|
||||
{ $ne: 2 },
|
||||
{ $ne: 3 }
|
||||
]
|
||||
}
|
||||
__INVO_ID__: 'oev3yzmydgdvtxg82zbzmrl6gbu73ax7'
|
||||
})
|
||||
|
||||
console.log(">>>>>>>>>>>>>>>>>>>>")
|
||||
|
32
docs/invodb使用文档.md
Normal file
32
docs/invodb使用文档.md
Normal file
@ -0,0 +1,32 @@
|
||||
# 简明 invoDB 使用教程
|
||||
|
||||
|
||||
## 前置知识
|
||||
|
||||
### 什么是 JSON 格式
|
||||
|
||||
是一种轻量级资料交换格式,其内容由属性和值所组成。
|
||||
|
||||
`json` 可以同样被看作 `JavaScript` 对象的一个子集。
|
||||
|
||||
#### 一个典型的 JSON 对象
|
||||
|
||||
```json
|
||||
{
|
||||
"id": 7,
|
||||
"title": "这是一篇文章",
|
||||
"content": "这是文章内容",
|
||||
"author": "YuhangQ",
|
||||
"category": "数据库",
|
||||
"tags": ["数据库", "C++", "数据结构"],
|
||||
"parameters": {
|
||||
"hidden": true,
|
||||
"like": 25565,
|
||||
},
|
||||
"comment": [
|
||||
{"username": "YuhangQ", "content": "文章写的真不错!"},
|
||||
{"username": "TechCiel", "content": "能提供下打赏渠道吗?"},
|
||||
]
|
||||
}
|
||||
```
|
||||
|
@ -5,7 +5,8 @@
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "clear && node-gyp build && node demo/test.js",
|
||||
"install": "node-gyp rebuild"
|
||||
"install": "node-gyp rebuild",
|
||||
"build": "node-gyp build"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
|
@ -228,7 +228,13 @@ std::set<nlohmann::json> Collection::innerQuery(const std::string &prefix, const
|
||||
std::set<nlohmann::json> tmp;
|
||||
std::string tPrefix = prefix + key;
|
||||
|
||||
if(key == "$or") {
|
||||
if(key == "__INVO_ID__") {
|
||||
int add = uuid->find(value);
|
||||
if(add != -1) {
|
||||
tmp.insert(PageManager::readJSONFromFile(add));
|
||||
}
|
||||
}
|
||||
else if(key == "$or") {
|
||||
nlohmann::json line = json[key].get<nlohmann::json>();
|
||||
for(auto& obj : line) {
|
||||
tmp = setUnion(tmp, innerQuery(prefix, obj.get<nlohmann::json>()));
|
||||
|
@ -8,6 +8,14 @@
|
||||
Collection *col;
|
||||
|
||||
void terminal() {
|
||||
|
||||
PageManager::loadDatabase("test.invodb");
|
||||
Collection::loadCollections();
|
||||
|
||||
if (!Collection::existsCollection("test"))
|
||||
Collection::createCollection("test");
|
||||
col = &Collection::getCollection("test");
|
||||
|
||||
printf("--------INVODB TERMINAL--------\n");
|
||||
printf("insert\t<JSON>\tinsert a one line json to database.\n");
|
||||
printf("query\t<JSON>\tquery all jsons satisfying the query json.\n");
|
||||
|
Loading…
x
Reference in New Issue
Block a user