GithubHelp home page GithubHelp logo

sequelize-datatable's Introduction

Sequelize Datatable

Server-side datatables with Sequelize (works with Sequelize 3 and 4). This package was originally forked from sequelize-datatables.

Support

  • Node.js v4 & later
  • Sequelize v3 & later

Instalation

npm install sequelize-datatable

API

datatable(
  model: SequelizeModel required,
  config: Object required,
  params: Object,
  options: Object
) -> Promise<Object>

This function takes three arguments to produce output for datatables.

  • model - required - is the sequelize model.
  • config - required - is config sent by jQuery datatables to our server.
  • params - options for sequelize query.
  • options - library specific options. See below

Options

  • caseInsensitive: Boolean - A flag for postgresql dialec. If this is set to true, ILIKE will be used instead of LIKE Default to false.

Example Usage

const datatable = require(`sequelize-datatable`);
const model = require(`./path/to/sequelize-model`); // Sequelize model

// assuming you are using express

route.get(`/datasource`, (req, res) => {
  datatable(model, req.query, {})
    .then((result) => {
      // result is response for datatables
      res.json(result);
    });
});

Todo

  • Test with postgresql database
  • Test with mysql database
  • Support global search
  • Support nested relation search & ordering
  • Test with another database server (mssql, sqlite)
  • Support individual column search
  • More tests!

Testing

You must have docker installed on your system if you want to test this module on your machine.

git clone https://github.com/husnulhamidiah/sequelize-datatable.git
cd sequelize-datatable-node
npm install

# It's recommended to test this library using dockerized database engine
DIALECT=mysql npm run test:setup

# or

DIALECT=postgres npm run test:setup

# on another terminal, enter command
DIALECT=postgres npm test

# or

DIALECT=mysql npm test

sequelize-datatable's People

Contributors

husnulhamidiah avatar nullivex avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.