by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Nick Porter
    @surjikal
    This is the best library ever!
    Is there a way to do UNIONs?
    John Fawcett
    @jrf0110
    @surjikal thanks! And yes, there sure is
    It looks something like this:
    {
      type: 'union'
    , all: true
    , queries: [
        { type: 'select', table: 'users' }
      , { type: 'select', table: 'other_users' }
      ]
    };
    Nick Porter
    @surjikal
    amazing, thank you!
    Also I realize that this library is made for introspection, but sometimes I would love to be able to add a raw SQL subquery in my object. Is this possible?
    John Fawcett
    @jrf0110
    I'm sure it is, but I'm a little unclear of your meaning. Can you provide an example of what you'd like to accomplish?
    Nick Porter
    @surjikal
    Maybe something like like:
      var someGroup = {
        type:     'raw'
      , sql: 'select * from users where user.id = 5'
      }
    
      var query = {
        type:   'select'
      , table:  'users'
      , where:  { id: { $nin: someGroup } }
      };
    Nick Porter
    @surjikal
    I know this can be implemented with the library easily, this is just an example
    John Fawcett
    @jrf0110
    Ah I see what you mean, @surjikal
    expressions can take a wide range of arguments
    I find using the array syntax most helpful (for maintaining parameterized queries)
    Using exactly your example would yield:
    var someGroup = {
      expression: 'select * from users where user.id = 5'
    };
    
    var query = {
      type: 'select'
    , table: 'users'
    , where: {
        id: {
          $nin: someGroup
        }
      }
    };
    JohnZorn
    @nakedcity
    Hi is there any mapping from json to mongo operation
    ?
    where the resulting type = select turn into something like findOne?
    John Fawcett
    @jrf0110
    @samio80 dirac might be what youer' looking for, but the API is jrf0110/dirac#54
    Ariel Barabas
    @knoid
    Hi all!
    Is there a way to do something like "select * from users where lower(email) = 'asd@a.com'?
    Ariel Barabas
    @knoid
    ended up doing this:
    mosql.conditionalHelpers.add('$lower', (column, value) => {
      return `lower(${column}) = ${value}`
    })