Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
kmore for midway framework.
npm install egg-kmore knex
# Then add one of the following:
npm install pg
npm install mssql
npm install oracle
npm install sqlite3
Edit ${app_root}/src/config/plugin.ts
:
import { EggPlugin } from 'midway'
export default {
kmore: {
enable: true,
package: 'egg-kmore',
},
} as EggPlugin
/* location: ${app_root}/src/config/config.${env}.ts */
import { EggKmoreConfig, genTbListFromType, ClientOpts } from 'egg-kmore'
import { TbListModel } from '../app/user/user.model'
const master: ClientOpts = {
knexConfig: {
client: 'pg',
connection: {
host: 'localhost',
user: 'postgres',
password: '',
database: 'db_ci_test',
},
acquireConnectionTimeout: 10000,
},
tables: genTbListFromType<TbListModel>(),
}
// app: default true
export const kmore: EggKmoreConfig = {
client: master,
}
/* location: ../app/user/user.model.ts */
export interface TbListModel {
tb_user: User
tb_user_detail: UserDetail
}
/**
* user info
*/
export interface UserInfo extends User, UserDetail {
}
export interface User {
uid: number
user_name: string
}
export interface UserDetail {
uid: number
phone: string
email: string
}
export interface GetUserOpts {
uid: number
}
/* location: ../app/user/user.service.ts */
import { provide, plugin } from 'midway'
import { DbModel } from 'egg-kmore'
import { GetUserOpts, UserInfo, User, TbListModel } from './user.model'
@provide()
export class UserService {
constructor(
@plugin('kmore') private readonly db: DbModel<TbListModel>,
) { }
/**
* Read user info
*/
public async getUser(options: GetUserOpts): Promise<UserInfo> {
const { rb, tables: t } = this.db
const row: UserInfo = await rb.tb_user()
.innerJoin(
t.tb_user_detail,
`${t.tb_user}.uid`,
`${t.tb_user_detail}.uid`,
)
.select('*')
.where(`${t.tb_user}.uid`, options.uid)
.then(rows => rows[0])
return row
}
/**
* Read user_name
*/
public async getUserName(options: GetUserOpts): Promise<User['user_name']> {
const { rb } = this.db
const name = await rb.tb_user()
.select('user_name')
.where('uid', options.uid)
.then(rows => rows[0] ? rows[0].user_name : '')
return name
}
}
The files generated automatically under typescript environment for debug or test
cd ${app_root}
kmore gen --path ./src
// then you could build the project
npm run build
5.1.0 (2021-05-29)
Note: Version bump only for package kmore
FAQs
egg plugin of kmore
The npm package egg-kmore receives a total of 0 weekly downloads. As such, egg-kmore popularity was classified as not popular.
We found that egg-kmore demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.