# lc-schedule-by-pg

> 通过读取pg数据库记录来执行工作计划。

Latest version **1.0.14** (published 2020-04-22) · ISC license · 0 weekly downloads

## Install

```sh
npm install lc-schedule-by-pg
pnpm add lc-schedule-by-pg
yarn add lc-schedule-by-pg
bun add lc-schedule-by-pg
```

## 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.14 |
| Published | 2020-04-22 |
| First published | 2020-04-21 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 7.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | linc |
| Maintainers | sulirlin |

## Links

- npm: https://www.npmjs.com/package/lc-schedule-by-pg
- Repository: https://github.com/sulirlinc/lc-schedule-by-pg
- Homepage: https://github.com/sulirlinc/lc-schedule-by-pg#readme
- Issues: https://github.com/sulirlinc/lc-schedule-by-pg/issues
- npm.io page: https://npm.io/package/lc-schedule-by-pg

## Dependencies (2)

- [lc-pg-dao](https://npm.io/package/lc-pg-dao.md) latest
- [lc-js-common](https://npm.io/package/lc-js-common.md) latest

## Recent versions

- 1.0.14 (latest) — 2020-04-22
- 1.0.13 — 2020-04-21
- 1.0.12 — 2020-04-21
- 1.0.11 — 2020-04-21
- 1.0.10 — 2020-04-21
- 1.0.9 — 2020-04-21
- 1.0.8 — 2020-04-21
- 1.0.7 — 2020-04-21
- 1.0.6 — 2020-04-21
- 1.0.5 — 2020-04-21
- 1.0.4 — 2020-04-21
- 1.0.3 — 2020-04-21
- 1.0.2 — 2020-04-21
- 1.0.1 — 2020-04-21
- 1.0.0 — 2020-04-21

## README

# lc-schedule-by-pg
持久化工作计划：当前设计，主要是为了把schedule丟到数据库中，通过添加数据库来满足添加启用或者停用schedule。

#默认值
* `tableName`: z_sys_schedule
* `persistence`: true
* `status`: 1 [1为启用，0为停用]

## 使用方法
schedule.js
```javascript

const LCSchedule = require('lc-schedule-by-pg')
const { pgConfig } = require("./config")
const logger = require('./logger')

LCSchedule.prototype.trigger = ({ event, method }) => {
  const fun = require(`./${ event }`);
  if (fun instanceof Function) {
    fun()[method]()
  } else if (fun[method] instanceof Function) {
    fun[method]()
  }
}

module.exports = new LCSchedule({ pgConfig, logger })

```

cachings.js

```javascript

module.exports = { 
  remove(){ 
  //Do your remove biz. 
  }
}
```

初始化应用，app.js 添加

```javascript

const mySchedule = require('./schedule')

const interval = 1;
mySchedule.addSchedule({ persistence: true, event: "cachings", method: "remove", timeUnit: "minutes", interval }).then(
    ({ triggerId }) => console.log(`启动内存定时每${ interval }分钟清理机制，triggerId:${ triggerId }。`)).catch(e => logger.error(e))


```

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