From 516fb18c823b742f7f853ad4ace89f7fcd08f863 Mon Sep 17 00:00:00 2001 From: YuhangQ Date: Sun, 5 Dec 2021 22:45:55 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=94=B9=E6=9F=A5=E8=AF=A2=E5=87=BD?= =?UTF-8?q?=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- benchmark/invodb.js | 1 - index.js | 10 ++++++++-- package.json | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/benchmark/invodb.js b/benchmark/invodb.js index e043d3d..81c14f5 100644 --- a/benchmark/invodb.js +++ b/benchmark/invodb.js @@ -3,7 +3,6 @@ const { execSync } = require("child_process") execSync("rm -rf benchmark.invodb") - let time = 0 function clock() { let last = time diff --git a/index.js b/index.js index bdfb45b..2edd3a3 100644 --- a/index.js +++ b/index.js @@ -17,7 +17,7 @@ function collection(collectionName) { let json = JSON.stringify(object); core.remove(collectionName, json); } - function query(object) { + function find(object) { if(!core.exists(collectionName)) throw `Collection ${collectionName} doesn't exists!`; let json = JSON.stringify(object); let res = []; @@ -26,12 +26,18 @@ function collection(collectionName) { } return res; } + function findOne(object) { + let res = find(object); + if(res.length >= 1) return res[0]; + return undefined; + } return { exist: exist, create: create, insert: insert, remove: remove, - query: query, + find: find, + findOne: findOne, update: insert } } diff --git a/package.json b/package.json index c279486..6bca899 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "invodb", - "version": "1.0.23", + "version": "1.1.0", "description": "a nosql json document database", "main": "index.js", "scripts": {