This package has been deprecated

Author message:

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

mysql-eloquent
TypeScript icon, indicating that this package has built-in type declarations

0.1.2-dev • Public • Published

mysql-eloquent

MySQL Wrapping library used like Laravel Eloquent

Installing

Using npm:

$ npm install mysql-eloquent

Using yarn:

$ yarn add mysql-eloquent

Examples

Select

Model.ts file

import MysqlEloquent from 'mysql-eloquent'

export default class Model<T> extends MysqlEloquent<T>
{
}

MdcinModel.ts file

import Model from './Model'

interface MdcinItem
{
  ADM_DISPS_SEQ: number; // 행정처분일련번호
  ENTP_NAME: string; // 업소명
  ADDR: string | null; // 업소소재지
  ENTP_NO: number; // 업허가번호
  ITEM_NAME: string; // 제품명
  BEF_APPLY_LAW: string | null; // 위반법명
  EXPOSE_CONT: string; // 위반내용
  ADM_DISPS_NAME: string; // 행정처분명
  LAST_SETTLE_DATE: number | null; // 행정처분일자 (최종확정일자)
  DISPS_TERM_DATE: string; // 행정처분기간
}

export default class MdcinModel extends Model<MdcinItem>
{

}

index.ts file

import MdcinModel from './MdcinModel'

const model = new MdcinModel()
const historyOne = await model.where('ENTP_NO', 20210811).orderBy('id', 'desc')->fist();

Upserts

import Model from './Model'

interface MdcinItem
{
  ADM_DISPS_SEQ: number; // 행정처분일련번호
  ENTP_NAME: string; // 업소명
  ADDR: string | null; // 업소소재지
  ENTP_NO: number; // 업허가번호
  ITEM_NAME: string; // 제품명
  BEF_APPLY_LAW: string | null; // 위반법명
  EXPOSE_CONT: string; // 위반내용
  ADM_DISPS_NAME: string; // 행정처분명
  LAST_SETTLE_DATE: number | null; // 행정처분일자 (최종확정일자)
  DISPS_TERM_DATE: string; // 행정처분기간
}

export default class MdcinModel extends Model<MdcinItem>
{
  /**
   * handle
   */
  public async do()
  {
    // from json response
    const items: Array<MdcinItem> = this.content.response.body.items.item;

    // upsert massive
    // ON DUPLICATED KEY `ADM_DISPS_SEQ`
    // UPDATE SET [ENTP_NAME, ADDR, ITEM_NAME]
    await this.upserts(items, 'ADM_DISPS_SEQ', ['ENTP_NAME', 'ADDR', 'ITEM_NAME']);

    return true;
  }
}

Package Sidebar

Install

npm i mysql-eloquent

Weekly Downloads

0

Version

0.1.2-dev

License

none

Unpacked Size

28.9 kB

Total Files

9

Last publish

Collaborators

  • byzz