# lgnvpr-nodejs

> As a CRUD support library for nodejs

Latest version **0.0.15** (published 2021-09-09) · ISC license · 0 weekly downloads

## Install

```sh
npm install lgnvpr-nodejs
pnpm add lgnvpr-nodejs
yarn add lgnvpr-nodejs
bun add lgnvpr-nodejs
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.15 |
| Published | 2021-09-09 |
| First published | 2021-04-29 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 11 |
| Unpacked size | 88 KB |
| Known vulnerabilities | 0 (+2 in 2 direct dependencies) |
| Install scripts | no |
| Maintainers | lgnvpr |
| Keywords | nodejs, crud-nodejs, postgres, crud, luong, base-crud |

## Links

- npm: https://www.npmjs.com/package/lgnvpr-nodejs
- Repository: https://github.com/luongdeveloper/npm-luong-nodejs
- Homepage: https://github.com/luongdeveloper/npm-luong-nodejs#readme
- Issues: https://github.com/luongdeveloper/npm-luong-nodejs/issues
- npm.io page: https://npm.io/package/lgnvpr-nodejs

## Dependencies (11)

- [i](https://npm.io/package/i.md) ^0.3.6
- [pg](https://npm.io/package/pg.md) ^8.7.1
- [npm](https://npm.io/package/npm.md) ^7.21.1
- [uuid](https://npm.io/package/uuid.md) ^8.3.2
- [lodash](https://npm.io/package/lodash.md) ^4.17.21
- [ts-node](https://npm.io/package/ts-node.md) ^10.2.1
- [sequelize](https://npm.io/package/sequelize.md) ^6.6.5
- [sqlstring](https://npm.io/package/sqlstring.md) ^2.3.2
- [@types/lodash](https://npm.io/package/@types/lodash.md) ^4.14.172
- [@types/sqlstring](https://npm.io/package/@types/sqlstring.md) ^2.3.0
- [luong-base-model](https://npm.io/package/luong-base-model.md) ^0.0.12

## Recent versions

- 0.0.15 (latest) — 2021-09-09
- 0.0.14 — 2021-09-09
- 0.0.13 — 2021-08-25
- 0.0.12 — 2021-08-03
- 0.0.11 — 2021-07-03
- 0.0.10 — 2021-07-01
- 0.0.9 — 2021-06-17
- 0.0.8 — 2021-06-15
- 0.0.7 — 2021-06-15
- 0.0.6 — 2021-05-16
- 0.0.5 — 2021-05-16
- 0.0.4 — 2021-05-01
- 0.0.3 — 2021-04-30
- 0.0.2 — 2021-04-29
- 0.0.1 — 2021-04-29

## README

# LGNV NodeJS

As a CRUD support library for nodejs


## Authors

- [@luongdeveloper](https://github.com/luongdeveloper)

  
## Installation

install npm package with npm i lgnvpr-nodejs

These are libraries inherited from **sequelize**, check them out here



**I have an object like this:**
```javascript
export class Product {
    id : string; 
    name : string; 
    price : number; 
    img : string;
    deletedAt : Date;
    createdAt: Date;
    updatedAt: Date; 
}
```


**Define a product Reponsitory:**
```javascript
const productAdapter = new AdapterSequelize({
    modelDefine: {
        id: {
            type: DataTypes.STRING,
            field: 'username',
        },
        name: {
            type: DataTypes.STRING,
            field: 'password',
        },
        price: { 
            type: DataTypes.STRING, 
            field: 'first_name' 
        },
        img: {
            type: DataTypes.STRING,
            field: 'last_name',
        },
        deletedAt: {
            type: DataTypes.STRING,
            field: 'phone',
        },
        createdAt: {
            type: DataTypes.STRING,
            field: 'address',
        }, //You can configure some other properties for the column, See detail Sequelize
    }, // define entity on database, 
    name: 'products', // table_name
    urlConnect: "postgres:your_username:your_password@host/database_name",
});
```

**Create or update entity**
```javascript
productAdapter.save(entity); // entity you want save to database 

productAdapter.saveBulk(entity); // create or update many entity 

productAdapter.createBulk(entitys); // create many entity 

productAdapter.updateBulk(entitys); // update many entity 


```

**Remove entity**
```javascript
productAdapter.remove({id : "id_entity"}); // id of entity


```

**Get list by paging**
```javascript
// The fields may not be passed, it will take the default value
productAdapter.list({
    page : 1, 
    pageSize : 20,
    search : "abc",
    searchFields : ["name"],
    sort : ["-name"],
    filter : {
        name : "abc",
        id : "uuid"
    },
    query : {} // query of sequelize
}); // id of entity
```

**Get list**
```javascript
// The fields may not be passed, it will take the default value
productAdapter.find({
    limit : 0, 
    offset : 1000,
    search : "abc",
    searchFields : ["name"],
    sort : ["-name"],
    filter : {
        name : "abc",
        id : "uuid"
    },
    query : {} // query of sequelize
}); // id of entity
```


**Query by paging**

*For complex queries with paging, search, and sort functions. and now it's so easy*
```javascript
// The fields may not be passed, it will take the default value
productAdapter.queryByPagination("select * from ....",{
    replacements : ... // see detail in sequelize lib
} ,{
    limit : 0, 
    offset : 1000,
    search : "abc",
    searchFields : ["name"],
    sort : ["-name"],
    filter : {
        name : "abc",
        id : "uuid"
    },
    query : {} // query of sequelize
}); // id of entity
```

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