incrediblesound / OpalDB

A straightforward zero-dependency in-memory database
16 stars 1 forks source link

Join #1

Closed mathiasrw closed 8 years ago

mathiasrw commented 8 years ago

Interesting.

Is it ment to support join on tables at some point?

incrediblesound commented 8 years ago

Yes, I think that would be in scope for this project! I'll look into implementing that.

incrediblesound commented 8 years ago

Hi @mathiasrw take a look in test/join.js and tell me what you think of that syntax!

mathiasrw commented 8 years ago
books
      .join('authorId')
      .to('authors')
      .where('name')
      .equals('James Joyce')

I would always think join XXX with YYY (and not to) - but im not native english, so its just an input for you. When you join tables you must state what fields the two tables should join on. It looks like the example is trying to "join" on a specific value. It must be that value in table a is equal to value in table b

I suggest a syntax where like this:

books
      .join(author, 'id')
      .on('authorId')

For multiply layers of join I suggest something along with:

books
      .join(author, 'id')
      .on('authorId')
      .join(sales, 'authorId')
      .on('author, 'id'')
incrediblesound commented 8 years ago

I'll try that, thanks for the input!