1.0.3 • Published 3 years ago

knection v1.0.3

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

Installation

$ npm install knection

Usage

const crud = require('knection');
const User = require('./models/User');

// Create query
const create = await crud.create(req /* request object */, User);

// Read query
const read = await crud.read(User);

// Filtered query
const read = await crud.readBy(User, 'id', 1);

// Query with graph fetched
const read = await crud.readWithGraph(User, 'task');

// Filtered query with graph fetched
const read = await crud.readWithGraphBy(User, 'task', 'id', 1);

// Update query
const update = await crud.update(
  req /* request object */,
  User,
  'name',
  'Updated Name'
);

// Delete query
const del = await crud.delete(User, 1);

Methods

NameDescription
create(req, model)Insert a new row with the data passed in the request object.
read(model)Get all rows of the passed model.
readBy(model, column, value)Get a row filtered by the passed params.
readWithGraph(model, graph)Get all rows and they related graph.
readWithGraphBy(model, graph, column, value)Get a single row and they related graph filtered by the passed params.
delete(model, id)Delete a row filtered by the passed id.
1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago