Skip to content

Instantly share code, notes, and snippets.

@tegila
Created April 5, 2019 04:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tegila/81e238afe10df5b626b37ca9d05eed46 to your computer and use it in GitHub Desktop.
Save tegila/81e238afe10df5b626b37ca9d05eed46 to your computer and use it in GitHub Desktop.
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