mirror of
https://github.com/YuhangQ/InvoDB.git
synced 2025-01-26 22:50:56 +00:00
更改查询函数
This commit is contained in:
parent
801c9c510b
commit
516fb18c82
@ -3,7 +3,6 @@ const { execSync } = require("child_process")
|
|||||||
|
|
||||||
execSync("rm -rf benchmark.invodb")
|
execSync("rm -rf benchmark.invodb")
|
||||||
|
|
||||||
|
|
||||||
let time = 0
|
let time = 0
|
||||||
function clock() {
|
function clock() {
|
||||||
let last = time
|
let last = time
|
||||||
|
10
index.js
10
index.js
@ -17,7 +17,7 @@ function collection(collectionName) {
|
|||||||
let json = JSON.stringify(object);
|
let json = JSON.stringify(object);
|
||||||
core.remove(collectionName, json);
|
core.remove(collectionName, json);
|
||||||
}
|
}
|
||||||
function query(object) {
|
function find(object) {
|
||||||
if(!core.exists(collectionName)) throw `Collection ${collectionName} doesn't exists!`;
|
if(!core.exists(collectionName)) throw `Collection ${collectionName} doesn't exists!`;
|
||||||
let json = JSON.stringify(object);
|
let json = JSON.stringify(object);
|
||||||
let res = [];
|
let res = [];
|
||||||
@ -26,12 +26,18 @@ function collection(collectionName) {
|
|||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
function findOne(object) {
|
||||||
|
let res = find(object);
|
||||||
|
if(res.length >= 1) return res[0];
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
return {
|
return {
|
||||||
exist: exist,
|
exist: exist,
|
||||||
create: create,
|
create: create,
|
||||||
insert: insert,
|
insert: insert,
|
||||||
remove: remove,
|
remove: remove,
|
||||||
query: query,
|
find: find,
|
||||||
|
findOne: findOne,
|
||||||
update: insert
|
update: insert
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "invodb",
|
"name": "invodb",
|
||||||
"version": "1.0.23",
|
"version": "1.1.0",
|
||||||
"description": "a nosql json document database",
|
"description": "a nosql json document database",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user