Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
console.log( "Must supply parameter 'add' or 'del'" );
//process.exit(0);
}
var Gun = require( "gun/gun" );
var gunDb = require( "." );
//var Gun = require( "gun" );
require('gun/lib/not')
require( "gun-unset" );
const rel_ = Gun.val.rel._; // '#'
const val_ = Gun._.field; // '.'
const node_ = Gun.node._; // '_'
var gun = new Gun( /*{ db:{ file:'gun.db' } }*/ );
console.log( new Date(), "Initialized gun instance" );
var root = gun.get( "db" );
var alice = root.get( "alice" )
alice.not( (val)=>{
console.log( "init alice data", val );
alice.put( { name: 'alice', dob: 'before now', whatever: 'one' } );
} );
var bob = root.get( "bob" )
bob.not( (val)=>{
console.log( "init bob data" , val);
bob.put( { name:'bob', dob: "yes", color: "purple" } );
} );
//process.on( "warning", (warning)=>{console.trace( "WARNING:", warning ); } );
//process.on( "error", (warning)=>{console.trace( "ERROR PROCESS:", warning ); } );
//process.on( "exit", (warning)=>{console.trace( "EXIT:", warning ); } );
const Gun = require('gun/gun');
var _debug_counter = 0;
var __debug_counter = 0;
var _debug_tick = Date.now();
const _debug = false;
const rel_ = Gun.val.rel._; // '#'
const val_ = Gun._.field; // '.'
const node_ = Gun.node._; // '_'
const state_ = Gun.state._; // '>';
var qb;
const ACK_ = '@';
const SEQ_ = '#';
Gun.on('opt', function(ctx) {
var goNext = function(){
this.to.next(ctx);
if (ctx.once) {
return;
}
}.bind(this);
//process.on( "error", (warning)=>{console.trace( "ERROR PROCESS:", warning ); } );
//process.on( "exit", (warning)=>{console.trace( "EXIT:", warning ); } );
const Gun = require('gun/gun');
const vfs = require("sack.vfs");
var _debug_counter = 0;
var __debug_counter = 0;
var _debug_tick = Date.now();
const _debug = false;
const rel_ = Gun.val.rel._; // '#'
const val_ = Gun.obj.has._; // '.'
const node_ = Gun.node._; // '_'
const state_ = Gun.state._;// '>';
const soul_ = Gun.node.soul._;// '#';
const ACK_ = '@';
const SEQ_ = '#';
Gun.on('opt', function(ctx){
this.to.next(ctx);
if(ctx.once){ return }
var opt = ctx.opt.db || (ctx.opt.db = {});
//opt.file = opt.file || ('file:gun.db?nolock=1');
opt.file = opt.file || ('gun.db');
var client = vfs.Sqlite(opt.file);
var gun = ctx.gun;
if( !client ) {
console.log( "Failed to open database:", opt.file );
return;
}
put: function(key, node, done) {
if (this.initialized) {
// Optional Key Storage
if (this.store_keys) {
// Emulate Elassandra Table w/ node KV
var rows = [];
var row_insert = { index: { _index: this.store_keys_index, _type: this.store_keys_type } };
Gun.node.is(node, function(a,b,c,d) {
var row = { field: b, soul: d, state: new Date().getTime() };
if (c[b] instanceof Object ) {
row.relation = c[b]['#'];
} else {
row.value = c[b];
}
rows.push(row_insert);
rows.push(row);
_debug && console.log(row);
});
this.db.bulk({
body: rows
}, function (err, resp, status) {
_debug && console.log(err,resp,status);
if(err) _debug && console.log(err);
//process.on( "warning", (warning)=>{console.trace( "WARNING:", warning ); } );
//process.on( "error", (warning)=>{console.trace( "ERROR PROCESS:", warning ); } );
//process.on( "exit", (warning)=>{console.trace( "EXIT:", warning ); } );
const Gun = require('gun/gun');
const vfs = require("sack.vfs");
var _debug_counter = 0;
var __debug_counter = 0;
var _debug_tick = Date.now();
const _debug = false;
const rel_ = Gun.val.rel._; // '#'
const val_ = Gun.obj.has._; // '.'
const node_ = Gun.node._; // '_'
const state_ = Gun.state._;// '>';
const soul_ = Gun.node.soul._;// '#';
const ACK_ = '@';
const SEQ_ = '#';
Gun.on('opt', function(ctx){
this.to.next(ctx);
if(ctx.once){ return }
var opt = ctx.opt.db || (ctx.opt.db = {});
//opt.file = opt.file || ('file:gun.db?nolock=1');
opt.file = opt.file || ('gun.db');
var client = vfs.Sqlite(opt.file);
var gun = ctx.gun;
if( !client ) {
console.log( "Failed to open database:", opt.file );
records.forEach(function(record){
var soul = Gun.node.soul(record);
if(soul && record.id && record.updatedAt){
all = Gun.state.ify(all, record.id, parseFloat(record.updatedAt), Gun.val.rel.ify(soul), table);
Gun.obj.del(record, 'createdAt');
Gun.obj.del(record, 'updatedAt');
Gun.obj.del(record, 'deletedAt');
Gun.obj.del(record, 'revokedAt');
graph[soul] = record;
//gun.on('in', {'@': at['#'], put: Gun.graph.node(record)});
}
});
// TODO: Convert to streaming - including getting MasterQuest to stream records.
const union = function union(vertex, node, opt){
if(!node || !node._){ return }
vertex = vertex || Gun.state.to(node);
if(!vertex || !vertex._){ return }
opt = Gun.num.is(opt)? {machine: opt} : {machine: Gun.state()};
opt.union = Gun.obj.copy(vertex); // Slow performance.
if(!Gun.node.is(node, function(val, key){
var HAM = Gun.HAM(opt.machine, Gun.state.is(node, key), Gun.state.is(vertex, key, true), val, vertex[key]);
if(!HAM.incoming){ return }
Gun.state.to(node, key, opt.union);
})){ return }
return opt.union;
}
/* eslint-enable */
;(function(){
var ify = Gun.node.ify, u;
Gun.chain.time = function(data, a, b){
if(data instanceof Function){
return travel(data, a, b, this);
}
var gun = this, root = gun.back(-1);
var cb = (a instanceof Function && a) || (b instanceof Function && b);
if(Gun.is(data)){
data.get(function(soul){
if(!soul){
return cb && cb({err: "Timegraph cannot link `undefined`!"});
}
gun.time(Gun.val.link.ify(soul), a, b);
}, true);
return gun;
}
opt = (cb === a)? b : a;
if(parseFloat(k) < parseFloat(next)){ return k }
});
if(!less){
find(o, cb, root, at.slice(0,-1), true);
} else {
var tmp = (at || o.at).slice();
tmp.push(less);
(o.low = tmp.slice()).push(Infinity);
find(o, cb, root, tmp, true);
}
}
if(off){ return }
if(!o.next){ return }
if(at < o.start.slice(0, at.length)){ return }
var n = [o.id].concat(now()), top = n[at.length];
Gun.node.is(msg.put, function(v, k){
if(k > top){ return }
(v = at.slice()).push(k);
find(o, cb, root, v, false);
});
})
}