This commit is contained in:
Iuri Matias 2019-11-07 16:38:06 -05:00
parent b8862e44bb
commit db56fe213f
4 changed files with 2 additions and 133 deletions

View File

@ -1,80 +0,0 @@
const stringify = require("json-stringify-safe");
const RxDB = require('rxdb');
RxDB.plugin(require('pouchdb-adapter-node-websql'))
function jsonFunctionReplacer(_key, value) {
if (typeof value === 'function') {
return value.toString();
}
return value;
}
const schemaWithIndexes = {
version: 0,
title: 'human schema no compression',
keyCompression: false,
type: 'object',
properties: {
uid: {
type: 'string',
primary: true // <- an index for firstName will now be created
},
values: {
type: 'string',
final: false
}
}
};
function test() {
RxDB.create({
name: 'mydatabase',
adapter: 'websql' // name of the adapter
}).then((x) => {
this.db = x;
this.db.collection({
name: 'embarklogs',
schema: schemaWithIndexes
}).then(() => {
let _data = {id: "123", foo: 1, bar: 2}
// this.db.embarklogs.insert({uid: _data.id, values: stringify(_data, jsonFunctionReplacer, 2)})
console.dir("===============")
this.db.embarklogs.upsert({uid: _data.id, values: stringify(_data, jsonFunctionReplacer, 2)})
// this.db.embarklogs.upsert({uid: _data.id, values: "123"})
setTimeout(() => {
let getNode = this.db.embarklogs.find().where('uid').eq(_data.id).exec().then((n) => {
// console.dir(n)
n.update({$set: {values: "123"}});
});
}, 3 * 1000);
// console.dir("===============")
// let getNode = this.db.embarklogs.find().where('uid').eq(_data.id).exec().then((n) => {
// n.update({$set: {values: "123"}});
// });
// getNode.update({$set: {values: "123"}});
// console.dir("===============")
setTimeout(() => {
this.db.embarklogs.dump().then(console.dir)
}, 10*1000);
// this.db.embarklogs.findOne(_data.id).exec().then((doc) => {
// console.dir("=== doc")
// console.dir(doc)
// })
// addRecord({
// session: this.session,
// id: this.session,
// timestamp: Date.now(),
// value: "new_session",
// type: "new_session",
// name: "new_session"
// }, this.db)
})
});
}
test();

View File

@ -138,7 +138,6 @@
"json-parse-better-errors": "1.0.2",
"lodash.clonedeep": "4.5.0",
"mocha": "6.2.0",
"mongoose": "5.7.7",
"neo-blessed": "0.2.0",
"node-http-proxy-json": "0.1.6",
"node-ipc": "9.1.1",
@ -147,12 +146,10 @@
"os-locale": "3.0.1",
"parse-json": "4.0.0",
"pkg-up": "2.0.0",
"pouchdb-adapter-node-websql": "7.0.0",
"promptly": "2.2.0",
"propose": "0.0.5",
"pump": "3.0.0",
"request": "2.88.0",
"rxdb": "8.7.2",
"semver": "5.6.0",
"shelljs": "0.8.3",
"simples": "0.8.8",

View File

@ -29,16 +29,6 @@ function updateRecord(id, data) {
fs.appendFileSync(LOGFILE, "\n" + stringify(data, jsonFunctionReplacer, 0));
}
// setTimeout(() => {
// // console.dir(DB);
// let value = JSON.parse(stringify(DB, jsonFunctionReplacer, 2));
// // fs.writeJSONSync("./log.json", DB);
// fs.writeJSONSync("./log_all.json", value);
// process.exit(0);
// }, 60*1000);
class SuperLog extends Logger {
startSession() {
@ -75,17 +65,9 @@ class SuperLog extends Logger {
}
log(values) {
// console.log("=> logging")
// console.log(values.id)
if (values.id) {
// console.log("=> has an id")
// let existingLog = findRecord(values.id);
// console.log("=> record found")
// if (existingLog) {
updateRecord(values.id, values)
return values.id;
// }
updateRecord(values.id, values)
return values.id;
}
let id = uuid.v4();
@ -123,32 +105,3 @@ class SuperLog extends Logger {
module.exports = SuperLog;
// session
// branch
// branch
// cmd_controller
// * startSession()
// * module
// * log
// * branch off
// API:
// logger.startSession() - to start tracking logs
// let id = logger.tag({whatever-you-want}) - appends {whatever-you-want} to a mongo db, associated to the current session id
// let sub_id = logger.tag({parent_id: id, ...whatever-you-want}) - appends {whatever-you-want} to a mongo db, associated to the current session id and parent_id id
// - name (e.g module name, method name)
// - type (e.g module init, function call, event)
// - inputs
// - outputs
// - timestamp
// - file/origin (can kinda be done automatically almost)
// for inputs and outputs
// let sub_id = logger.tag({parent_id: id, ...whatever-you-want})
// logger.tag({id: sub_id, inputs: xyz})
// .... code
// // gonna return
// logger.tag({id: sub_id, outputs: [1,2,3]})
// return [1,2,3]

View File

@ -146,7 +146,6 @@ Blockchain.doConnect = function(connectionList, opts, doneCb) {
let connectionErrs = {};
reduce(connectionList, false, function(result, connectionString, next) {
debugger;
if (result.connected) {
return next(null, result);
} else if (result) {