1.5.0 • Published 2 years ago

mql-to-jql v1.5.0

Weekly downloads
9
License
MIT
Repository
github
Last release
2 years ago

mql-to-jql

Node.js Test Runner GitHub code size in bytes GitHub package.json version GitHub

Convert mql syntax to jql to query ejdb databases

Installation

npm install --save mql-to-jql

Example usage

const convert = require('mql-to-jql/convert')
const createQuery = require('mql-to-jql/createQuery')

const db = await EJDB2.open('./example.db', { truncate: true });
const query = convert({
  fields: [
    'firstName',
    'lastName'
  ],

 // The following equality operators are implemented:
 // '$eq', '$ne', '$gt', '$gte', '$lt', '$lte', '$exists', '$null', '$in', '$nin'
  query: {
    $or: [
      { a: 1 },
      { a: 5 },
    ]
  },

  order: [
    'asc(firstName)',
    'desc(lastName)'
  ],

  limit: 10,
  skip: 100
});

/*
You can use query by sending it straight to ejdb.
query === {
  mql: '(/[[* = :?] = :?] or /[[* = :?] = :?])',
  values: ['a', 1, 'a', 5]
}
*/

// OR you can use the createQuery helper to do it for you
const q = createQuery(db, 'testCollection', query);
const records = await q.list();

console.log(records);

License

This project is licensed under the terms of the MIT license.

1.5.0

2 years ago

1.4.1

2 years ago

1.4.0

3 years ago

1.2.0

3 years ago

1.3.0

3 years ago

1.2.1

3 years ago

1.1.9

3 years ago

1.1.8

3 years ago

1.1.7

4 years ago

1.1.6

4 years ago

1.1.5

4 years ago

1.1.4

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.1.3

4 years ago

1.1.2

4 years ago

1.0.2

4 years ago

1.0.0

4 years ago