3 ms·
So basically db.hello = {world: ["foo", "bar"]}; vs db.set("hello", JSON.stringify( {world: ["foo", "bar"]})) Why we don't have macros already
by est 10y ago
So basically
db.hello = {world: ["foo", "bar"]};
vs
db.set("hello", JSON.stringify(
{world: ["foo", "bar"]}))
Why we don't have macros already.
- CapacitorSet 10y agoWhat do you mean by micros? Anyway, yeah, it's just meant to be some sort of synchronous syntactic sugar on Redis. Edit: I think you meant macros. In that case, consider that it's not as simple as that, because a) the redis library is only asynchronous, and b) such an approach requires to implement wrappers for every function that writes to the object, eg. Array.proto.splice.
- binarymax 10y agoNice use of proxies and deasync. Will definitely make for cleaner code, and looks like a good simple pattern that can be implemented elsewhere.
- z3t4 10y agoBecause in your second example you can not: var world = db.hello.world; world.push("baz");
- madeofpalk 10y agoWe ~kind of~ do have macros in the form of preprocessors like Babel. Probably not the best use of it though.