edgedb-js
edgedb-js copied to clipboard
Query builder: globals
Proposed API: expose a top-level e.global object containing references. This global object would be created in every module that includes 1+ globals.
e.global.user_id;
e.my_module.global.foo;
More succinct and better autocompletion than e.global("user_id")
Is an implementation of setnecessary or will this be abstracted away by the client API?
e.set(e.global.user_id, e.uuid_generate_v1mc());
// possible method form
e.global.user_id.set(e.uuid_generate_v1mc());
Hm, I'm not sure why we need this. The proposed global state client API works at the client connection level, not at the qb level:
session = client.withGlobals({user_id: my_user_id})
...
return await session.run(query)
Is an implementation of set necessary or will this be abstracted away by the client API?
That's why I asked this ☝️
But we still need a way to reference global variables in queries, no?
That's why I asked this ☝️
Got it :) Yeah, I was mostly talking about e.set() -- don't think we need it that much.
But we still need a way to reference global variables in queries, no?
For that e.globals.xxx should work. Agree that it's better than calling a function. Globals should "feel" like variables.