0.0.5 • Published 7 years ago

wc-query-sequelize v0.0.5

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

Express req.query -> sequelize find object

Simple use in graphQL controller:

import wQueryS from 'wc-query-sequelize'

const items = {
  type: new GraphQLList(Type),
  description: 'get item list',
  args: {
    limit : { type: IntType},
    skip  : { type: IntType},
    order : { type: StringType},
    name  : { type: StringType},
  },
  resolve( request, args, session) {
    const options = wQueryS(args);
    return Model.findAll(options);
  }
{items(limit:16, order:'-updatedAt', name:"~test" ){id name}}
SELECT * FROM `Items` WHERE LOWER(`name`) LIKE '%test%' ORDER BY `Items`.`updatedAt` DESC LIMIT 16;

Comparison Query Operators

EQ

  • url: /api/item?name=test
    • name: 'test'

NEQ

  • url: /api/item?name=!test
    • name: {$ne:'test'}

LT, LTE, GT, GTE

  • LT <
  • LTE [
  • GT >
  • GTE ]

  • url: /api/item?name=>test

    • name: {$gt:'test'}

IN, NIN

  • IN - @
  • NIN - #

  • url: /api/item?name=@1|2|3

Lower Like

url: /api/item?name=~test

{
 "name": {
  "attribute": {
   "fn": "lower",
   "args": [
    {
     "col": "name"
    }
   ]
  },
  "comparator": "=",
  "logic": {
   "$like": "%test%"
  }
 }
}

Evaluation Query Operators

Sort

Limit, Skip

  • /api/item?limit=5&skip=5
    • { offset: 5, limit: 5 }
0.0.5

7 years ago

0.0.4

8 years ago

0.0.3

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago