nherment / seneca-postgresql-store

PostgreSQL plugin for Seneca MVP
MIT License
3 stars 11 forks source link

Complex query support... #13

Open imjoshholloway opened 9 years ago

imjoshholloway commented 9 years ago

I've got a use-case where it would be great to have the following functionality:

OR functionality:

seneca.make$('foo').list({col1: 'val', or$: {col1: 'val2'}}, function (err, result) {
  ... SELECT * FROM foo where col1 = 'val' OR col1 = 'val2';
});

IN functionality

seneca.make$('foo').list({col1: {in$: ['val1', 'val2']}}, function (err, result) {
  ... SELECT * FROM foo where col1 IN ('val1', 'val2');
});

This could be doubled up to allow support of the @> JSONB operator if the value of the in$ key is an object:

seneca.make$('foo').list({json: {in$: {something: 'in-json'}}}, function (err, result) {
  ... SELECT * FROM foo where json @> '{"something": "in-json"}';
});

I'm going to have a crack at getting this working since I need it. Are there any suggestions / comments on the above - It would be great to be able to submit a pull request once I've got it working so thought I'd see what you guys think.

AdrianRossouw commented 8 years ago

I've gone a different direction, and started using knex.js as a query builder, which I just use to wire up the entity save/load/delete actions to my custom written queries.