# knection

> CRUD operations using knex and objection

Latest version **1.0.3** (published 2021-04-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install knection
pnpm add knection
yarn add knection
bun add knection
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2021-04-08 |
| First published | 2021-04-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 4.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Jose Gil |
| Maintainers | josefcogil27 |

## Links

- npm: https://www.npmjs.com/package/knection
- npm.io page: https://npm.io/package/knection

## Recent versions

- 1.0.3 (latest) — 2021-04-08
- 1.0.2 — 2021-04-07
- 1.0.1 — 2021-04-07
- 1.0.0 — 2021-04-07

## README

# Installation

```sh
$ npm install knection
```

# Usage

```js
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

| Name                                           | Description                                                            |
| ---------------------------------------------- | ---------------------------------------------------------------------- |
| `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.                                |

---
_Source: https://npm.io/package/knection · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
