3.0.0 • Published 5 years ago

loopback-api v3.0.0

Weekly downloads
15
License
MIT
Repository
github
Last release
5 years ago

Loopback API for Node.js

Installation

Loopback requires Node.js v4+ to run. If you want install Loopback local to your project use

$ npm install --save loopback-api

Or for global install use

$ npm install -g loopback-api

Usage

const LoopbackAPI = require('loopback-api').LoopbackAPI;
var loopbackAPI = new LoopbackAPI('http://localhost:3100/api');
var Users = loopbackAPI.getModel('Users');

// WITH PROMISE
Users.find({
    where: {
        name: 'Jon'
    }
}).then(users => {
    console.log('users: ', users);
});

// WITH ASYNC/AWAIT
async () => {
    var user = await Users.findById(1);
    console.log('user: ', user);
}();

Base methods

Each model has the following methods:

  • findById(id)
  • create(data)
  • count(where)
  • updateById(id, data)
  • find(filter)
  • findOne(filter)
  • update(where, data)
  • deleteById(id)
  • delete(where): deleteAll must be active on your server Loopback to use this method.

Where inputs are:

  • filter: is a JSON object containing the query filters. See filter Loopback.
  • where: is a JSON object containing specifies a set of logical conditions to match, similar to a WHERE clause in a SQL query. See where Loopback
  • data: is a JSON object containing the single model instance or an array instances.

Debug

When you start your application set DEBUG environment variable so you can see all debug messages of Loopback API package.

DEBUG=LP* node your_app.js

Contributors

Stefano31

License

MIT

3.0.0

5 years ago

2.0.1

6 years ago

2.0.0

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago