These are chat archives for orbitjs/orbit.js

23rd
Jan 2016
Oliver Searle-Barnes
@opsb
Jan 23 2016 12:47
@dgeb first cut of the query builder, orbitjs/orbit.js#244
bit undecided about the syntax for filters at the moment. Take a look at https://github.com/opsb/orbit.js/blob/query-builder/test/tests/orbit-common/unit/query-builder-test.js for examples of all the currently supported syntax.
I had a go at adding custom scopes on a per type basis, there’s an example at https://github.com/opsb/orbit.js/blob/query-builder/test/tests/orbit-common/unit/query-builder-test.js#L116
Dan Gebhardt
@dgeb
Jan 23 2016 15:16
@opsb looking really nice!
Oliver Searle-Barnes
@opsb
Jan 23 2016 15:17
thanks, yeah it came together pretty easily, because the oqe’s are composable anyway it was just a case of plugging them together at each build step
Dan Gebhardt
@dgeb
Jan 23 2016 15:18
yeah, pretty straightforward
I see you're using ES6 classes
even though you import Class
Oliver Searle-Barnes
@opsb
Jan 23 2016 15:18
yeah, if you check the logs I started off with Class
I switched to ES6 classes to get the scopes to work
possibly we can use Class, but I couldn’t see how
Dan Gebhardt
@dgeb
Jan 23 2016 15:20
I think we should probably make the decision to switch for the whole project at once
I'm nervous about mixing
Oliver Searle-Barnes
@opsb
Jan 23 2016 15:21
yeah, I was just trying to see if I could get the concept working really
happy to work it through with Class
Dan Gebhardt
@dgeb
Jan 23 2016 15:21
I think it's a cool concept, but definitely not required for v1
but maybe we can get it working with Class
Oliver Searle-Barnes
@opsb
Jan 23 2016 15:22
I suspect we can
So what I need to do is take a class and extend it by merging in a hash of methods
Dan Gebhardt
@dgeb
Jan 23 2016 15:24
you can call extend with multiple args
each hash will be merged
Oliver Searle-Barnes
@opsb
Jan 23 2016 15:24
i.e.
var SuperClass = Class.extend({

});

var newClass = SuperClass.extend({
  namedPluto() {
    return this.filterAttributes({name: 'Pluto'});
  }
});
ah
Dan Gebhardt
@dgeb
Jan 23 2016 15:24
+1
Oliver Searle-Barnes
@opsb
Jan 23 2016 15:24
so how would the extend call look?
doh, right
:)
that is in fact it then
I thought I tried that
will give it a go now
Dan Gebhardt
@dgeb
Jan 23 2016 15:25
:shipit:
I think we should benchmark Klassy vs Babel's ES6 class implementation before switching
for all I know the switch will boost perfs
Oliver Searle-Barnes
@opsb
Jan 23 2016 15:27
ah, hadn’t realised you’d extracted that
Dan Gebhardt
@dgeb
Jan 23 2016 15:27
oh yeah - d'oh!
I should actually remove it at some point too
and extract a few other libs too
Oliver Searle-Barnes
@opsb
Jan 23 2016 15:30
I suppose that gets us back to dependencies ;)
I’m really hoping we can just use npm and add it directly to the broccoli pipeline for ember-orbit
Dan Gebhardt
@dgeb
Jan 23 2016 15:31
yeah - npm alone will work for ember-orbit
Oliver Searle-Barnes
@opsb
Jan 23 2016 15:32
ah, I remember what caused me to switch to ES6 classes now
Dan Gebhardt
@dgeb
Jan 23 2016 15:33
what's that?
Oliver Searle-Barnes
@opsb
Jan 23 2016 15:33
how can you get a reference to the current class?
I wasn’t sure, thought I’d wait to ask you
Dan Gebhardt
@dgeb
Jan 23 2016 15:34
was going to say .constructor :/
Oliver Searle-Barnes
@opsb
Jan 23 2016 15:34
yeah, I did try :)
Dan Gebhardt
@dgeb
Jan 23 2016 15:35
hmmm ... let me investigate
Oliver Searle-Barnes
@opsb
Jan 23 2016 15:41
so yeah, this is what I ran into
Dan Gebhardt
@dgeb
Jan 23 2016 15:48
yeah
I'm seeing all that too
this might take some trickery to get right
Oliver Searle-Barnes
@opsb
Jan 23 2016 15:54
yeah :)
Dan Gebhardt
@dgeb
Jan 23 2016 15:54
I'm willing to accept using ES6 classes for query builders for now
Oliver Searle-Barnes
@opsb
Jan 23 2016 15:54
It seems like Class should work
I’m not getting where the disconnect is

it seems that

this.constructor

gets you the reference to the constructor for the current class, but it’s prototype only has the init method

which I suppose implies you’ve just got the root of the hierarchy
ah well
easy enough to change later
ok, I’ll leave it as is for now
Dan Gebhardt
@dgeb
Jan 23 2016 15:57
the args won't be applied - I suppose we could wrap the call
Oliver Searle-Barnes
@opsb
Jan 23 2016 15:57
it should be pretty isolated anyway
Dan Gebhardt
@dgeb
Jan 23 2016 15:58
yeah - that's fine
maybe we just do a sanity check and make the switch to ES6 classes anyway
Oliver Searle-Barnes
@opsb
Jan 23 2016 15:58
it’s the first question people are going to ask about the codebase now ;)
Dan Gebhardt
@dgeb
Jan 23 2016 15:59
it seems a bit crazy to use our own class system if we don't need to
in the beginning we needed to
Oliver Searle-Barnes
@opsb
Jan 23 2016 15:59
yeah, things have moved on
Dan Gebhardt
@dgeb
Jan 23 2016 15:59
right
Oliver Searle-Barnes
@opsb
Jan 23 2016 15:59
with babel the picture is completely different
Dan Gebhardt
@dgeb
Jan 23 2016 15:59
yeah
ok, well just remove the Class import for now and we can merge
Oliver Searle-Barnes
@opsb
Jan 23 2016 16:00
sure
I’m just going to add the relatedRecords operators. I wasn’t going to add them but I think we should probably always use the querybuilder
I’ve been thinking it probably makes sense for the query builder to be schema aware
Dan Gebhardt
@dgeb
Jan 23 2016 16:02
so you're thinking querybuilder stays in orbit-common? can't we have a simple version in orbit?
Oliver Searle-Barnes
@opsb
Jan 23 2016 16:03
I’m definitely planning on extracting a simpler version for orbit
was going to do that before we merge it
just wanted to work top down and extract
Dan Gebhardt
@dgeb
Jan 23 2016 16:03
sounds good then
ok, so you're going to keep working on the query-builder branch today?
Oliver Searle-Barnes
@opsb
Jan 23 2016 16:05
yeah, not sure how I’m going to do the orbit.js extraction yet but I’m hoping to crack that today
Dan Gebhardt
@dgeb
Jan 23 2016 16:06
ok, nice
Oliver Searle-Barnes
@opsb
Jan 23 2016 16:31
@dgeb regarding moving the QueryBuilder into orbit, my intention is to have an orbitjs QueryBuilder which is then extended by another QueryBuilder in orbit-common.
For this to make sense I think we really need to bring some operators over at the same time
  • andOperator
  • orOperator
  • equalOperator
  • getOperator
Those ones seem to make sense
Oliver Searle-Barnes
@opsb
Jan 23 2016 18:12
@dgeb I’ve done an extraction of the query-builder into orbit. I tried to avoid doing anything too abstract so I’ve just mirrored the query-builder structure across orbit and orbit-common. orbit-common simply extends the orbit classes with record related terms.
see opsb/orbit.js@391a29f