All Projects → fullcube → loopback-ds-paginate-mixin

fullcube / loopback-ds-paginate-mixin

Licence: MIT license
A mixin to provide pagination for loopback Model properties

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to loopback-ds-paginate-mixin

loopback-component-migrate
Migration framework for loopback
Stars: ✭ 43 (+38.71%)
Mutual labels:  mit, loopback, lb2, fullcube
loopback-component-mq
Loopback Component for working with a Message Queue
Stars: ✭ 19 (-38.71%)
Mutual labels:  mit, loopback, lb2
loopback-object-acl
Object-level ACL for Loopback Node.js framework
Stars: ✭ 13 (-58.06%)
Mutual labels:  loopback, loopback-mixin
Loopback Component Access Groups
Access controls for Loopback.
Stars: ✭ 56 (+80.65%)
Mutual labels:  mit, loopback
loopback-paginator
No description or website provided.
Stars: ✭ 13 (-58.06%)
Mutual labels:  loopback, loopback-mixin
Colmena
Colmena is a starter kit for an API with an Admin interface that can be easily extended and built upon.
Stars: ✭ 1,420 (+4480.65%)
Mutual labels:  mit, loopback
Crypto Notepad
🔑 Simple notepad for Windows with encryption features
Stars: ✭ 160 (+416.13%)
Mutual labels:  mit
Mit 6.824 2018
Solutions to mit 6.824 2018
Stars: ✭ 158 (+409.68%)
Mutual labels:  mit
Ifvisible.js
Crossbrowser & lightweight way to check if user is looking at the page or interacting with it.
Stars: ✭ 1,896 (+6016.13%)
Mutual labels:  mit
18s191
Course 18.S191 at MIT, Spring 2021 - Introduction to computational thinking with Julia:
Stars: ✭ 2,094 (+6654.84%)
Mutual labels:  mit
dwarlixir
A dwarf-fortress clone / MUD / side project in Elixir
Stars: ✭ 46 (+48.39%)
Mutual labels:  mit
MultiOS-USB
Boot operating systems directly from ISO files
Stars: ✭ 106 (+241.94%)
Mutual labels:  loopback
learn-how-to-build-a-mean-stack-application
The goal of this tutorial is to guide you through the coding of a full-stack JavaScript example application project and connecting a backend API to an Angular 5 front-end application employing the MEAN stack.
Stars: ✭ 55 (+77.42%)
Mutual labels:  loopback
Prettyconf
A extensible library for Settings/Code separation
Stars: ✭ 173 (+458.06%)
Mutual labels:  mit
Entia
Entia is a free, open-source, data-oriented, highly performant, parallelizable and extensible Entity-Component-System (ECS) framework written in C# especially for game development.
Stars: ✭ 28 (-9.68%)
Mutual labels:  mit
nuxt-loopback
Nuxt + Loopback template
Stars: ✭ 11 (-64.52%)
Mutual labels:  loopback
Zou
A simple and fast download accelerator, written in Rust
Stars: ✭ 145 (+367.74%)
Mutual labels:  mit
Node
Node.js JavaScript runtime ✨🐢🚀✨
Stars: ✭ 83,731 (+270000%)
Mutual labels:  mit
cms
🌌 The core infrastructure of FusionCMS.
Stars: ✭ 42 (+35.48%)
Mutual labels:  mit
Networklayerexample
Demo project for the article: http://szulctomasz.com/how-do-I-build-a-network-layer/ (Swift 3)
Stars: ✭ 250 (+706.45%)
Mutual labels:  mit

PAGINATION

Greenkeeper badge

Circle CI Coverage Status Dependencies semantic-release

This module is designed for the Strongloop Loopback framework. It provides a mixin that makes it easy to add paginate to an existing model

INSTALL

npm install --save loopback-ds-paginate-mixin

SERVER CONFIG

Add the mixins property to your server/model-config.json:

{
  "_meta": {
    "sources": [
      "loopback/common/models",
      "loopback/server/models",
      "../common/models",
      "./models"
    ],
    "mixins": [
      "loopback/common/mixins",
      "../node_modules/loopback-ds-paginate-mixin/lib",
      "../common/mixins"
    ]
  }
}

MODEL CONFIG

To use with your Models add the mixins attribute to the definition object of your model config.

{
    "name": "Item",
    "properties": {
        "name": "String",
        "description": "String",
        "status": "String"
    },
    "mixins": {
        "Paginate": {
            "limit": "10"
        }
    }
}

USAGE

// The basic
var request = {
  skip: 0,
  limit: 15,
  where: {
    status: 'active'
  }
}

// Using a Promise
Item.paginate(request).then(function(result) {
  // The first 15 active items are in result
  console.log(result);
}).catch(function(err){
  // Handle errors here
  console.error(err);
});

// Using a callback
Item.paginate(request, function(err, result) {
  // Handle errors here if err !== null
  if(err) console.error(err);
  // The first 15 active items are in result
  console.log(result);
});

// You can override the limit on a per-request base
var options = {
  limit: 5
}
Item.paginate(request, options).then(function(result) {
  // The first 5 active items are in result
  console.log(result);
}).catch(function(err){
  // Handle errors here
  console.error(err);
});

TESTING

Run the tests in test.js

  npm test

Run with debugging output on:

  DEBUG='loopback-ds-paginate-mixin' npm test
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].