Created
April 5, 2019 04:41
-
-
Save tegila/81e238afe10df5b626b37ca9d05eed46 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const find = (parent, query) => { | |
const payload = Object.assign({}, parent.payload, { | |
query | |
}); | |
const self = { | |
payload, | |
filter: query => { | |
payload.query = query; | |
return parent; | |
}, | |
value: () => payload | |
}; | |
return Object.assign(parent, self); | |
}; | |
const qb = (database, collection) => { | |
const payload = { | |
database, | |
collection | |
}; | |
const self = { | |
payload, | |
find: query => find(self, query) | |
}; | |
return self; | |
}; | |
const wss = target => { | |
let qb_instance; | |
const injector = { | |
send: () => { | |
return qb_instance.value(); | |
}, | |
listen: null | |
} | |
const self = { | |
qb: (database, collection) => { | |
const _qb = qb(database, collection) | |
qb_instance = Object.assign(_qb, injector); | |
return qb_instance; | |
}, | |
me: () => console.log(self), | |
on: null, | |
once: null | |
}; | |
return self; | |
}; | |
console.dir( | |
wss("google.com") | |
.qb("dbtest", "colltest") | |
.find({ bogo: "boo" }) | |
.filter({ mips: "fake" }) | |
.send() | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment