Browse Source

incomplete search in db.js

Dim Dim 6 years ago
parent
commit
c2b70ff9d3

+ 1 - 0
database/dal.js

@@ -0,0 +1 @@
+var db = require("./db.js");

+ 6 - 3
database/db.js

@@ -1,8 +1,11 @@
-var level = require('level');
+const level  = require('level');
+const sub    = require('level-sublevel');
+const search = require('level-search');
 
-var database = {
+const database = {
 	init: function(){
-		const db = level('./mydb');
+		this.db = sub(level("./mydb", {valueEncoding: 'json'}));
+		this.index = search(db, 'search');
 	},
 	open: function(callback){
 		return this.db.open(callback);

+ 17 - 0
database/db.test.js

@@ -0,0 +1,17 @@
+var database = require("./db.js");
+database.init();
+// database.put('namezzzzzz', {asd: "gdfhdfh"}, function (err) {
+//   if (err) return console.log('Ooops!', err) // some kind of I/O error
+
+//   // 3) Fetch by key
+//   database.get('namezzzzzz', function (err, value) {
+//     if (err) return console.log('Ooops!', err) // likely the key was not found
+
+//     // Ta da!
+//     console.log('name is=' + JSON.stringify(value))
+//   })
+// })
+
+database.put('namezzzzzz', {asd: "gdfhdfh"}).then(function(value){
+	return database.get('namezzzzzz');
+}).then(console.log);

BIN
database/mydb/000003.log


BIN
database/mydb/000005.ldb


BIN
database/mydb/000008.ldb


BIN
database/mydb/000023.ldb


BIN
database/mydb/000026.ldb


BIN
database/mydb/000028.ldb


BIN
database/mydb/000030.ldb


BIN
database/mydb/000033.ldb


BIN
database/mydb/000036.ldb


BIN
database/mydb/000037.log


BIN
database/mydb/000038.ldb


+ 1 - 1
database/mydb/CURRENT

@@ -1 +1 @@
-MANIFEST-000002
+MANIFEST-000035

+ 6 - 1
database/mydb/LOG

@@ -1 +1,6 @@
-2018/01/20-17:34:51.200 1344 Delete type=3 #1
+2018/01/20-19:13:30.720 1380 Recovering log #34
+2018/01/20-19:13:30.720 1380 Level-0 table #36: started
+2018/01/20-19:13:30.787 1380 Level-0 table #36: 201 bytes OK
+2018/01/20-19:13:30.877 1380 Delete type=0 #34
+2018/01/20-19:13:30.878 1380 Delete type=3 #32
+2018/01/20-19:13:30.879 b4 Compacting 4@0 + 0@1 files

+ 6 - 0
database/mydb/LOG.old

@@ -0,0 +1,6 @@
+2018/01/20-19:09:35.367 15d0 Recovering log #31
+2018/01/20-19:09:35.367 15d0 Level-0 table #33: started
+2018/01/20-19:09:35.440 15d0 Level-0 table #33: 201 bytes OK
+2018/01/20-19:09:35.553 15d0 Delete type=0 #31
+2018/01/20-19:09:35.554 15d0 Delete type=3 #29
+2018/01/20-19:09:35.606 11b0 Moved #23 to level-1 198 bytes OK: files[ 3 4 0 0 0 0 0 ]

BIN
database/mydb/MANIFEST-000002


BIN
database/mydb/MANIFEST-000035


+ 16 - 0
database/repositories/users.js

@@ -0,0 +1,16 @@
+const db = require("../db.js");
+
+const userRepository = {
+	login: function(){
+
+	},
+	register: function(obj){
+		
+
+	},
+	getByID: function(id){
+		return db.get("user:" + id);
+	},
+}
+
+module.exports = userRepository;