
Research
NPM targeted by malware campaign mimicking familiar library names
Socket uncovered npm malware campaign mimicking popular Node.js libraries and packages from other ecosystems; packages steal data and execute remote code.
npm install --save wink-dao
pnpm add --save wink-dao
import { useDao, useOrm, AutoTablePolicies, ColumnType, AutoIncrementEntity, ExecResult } from 'wink-dao';
// DAO基础操作库
const dao = useDao({
config: {
host: '',
port: 0,
user: '',
password: '',
datebase: '',
},
});
const { exec, get, select, insert, update, remove, revoke } = dao;
// 使用ORM框架
const { registRepository } = useOrm(dao, {
// 开启自动托管数据表后会自动创建表,表名会自动增加前缀t_,并将表名和字段名的驼峰命名转为下划线
// TODO 自动同步更新表结构暂未实现
autoTablePolicy: AutoTablePolicies.CREATE,
});
// 定义Menu模型,推荐使用自增主键
class Menu extends AutoIncrementEntity {
name?: string;
code?: string;
sort?: number;
isDirectory?: boolean;
constructor(data?: Partial<Menu>) {
super();
Object.assign(this, data);
}
}
// 配置Menu仓库
const repository = registRepository({
name: 'menu',
columnDefiens: [
{
name: 'name',
type: ColumnType.STRING,
length: 20,
required: true,
},
{
name: 'code',
type: ColumnType.STRING,
length: 20,
required: true,
primary: true,
unique: true,
},
{
name: 'sort',
type: ColumnType.INT,
required: true,
defaultValue: '0',
},
{
name: 'isDirectory',
type: ColumnType.BOOLEAN,
required: true,
defaultValue: 'false',
},
],
});
// 实际应该在项目启动时初始化
await repository.init.run();
// 插入数据
const id = await repository.create(new Menu({ code: 'test', name: '测试' }));
// 主键查询
const menu = await repository.get<Menu>(id);
// 更新数据
menu.sort = 10;
let isSuccess: boolean = await repository.update(menu);
// 条件查询
const list: Menu[] = await repository.select<Menu>({ code: 'test' });
// 逻辑删除
isSuccess = await repository.remove(id);
// 逻辑恢复
isSuccess = await repository.revoke(id);
// 自定义查询
const menus: Menu[] = await repository.exec<Menu[]>('select * from t_menu where sort > ?', [0]);
// 自定义操作
const result: ExecResult = await repository.exec('delete from menu where id = ?', [id]);
// result.affectedRows === 1
ORM
框架Mysql
耦合,改为插件形式DAO
基础能力JPA
实现通过函数名特殊命名规则生成复杂查询vitepress
文档项目并完善文档vitest
测试用例完善开发发布流程向文可
欢迎大家随时点击这里为我提供贡献、问题和功能建议
如果觉得项目对你有帮助,就帮我点个小星星吧~ ⭐️
本文档使用readme-md-generator模板生成
FAQs
欢迎使用WinkDao 👋 <img alt="Documentation" src="https:
The npm package wink-dao receives a total of 0 weekly downloads. As such, wink-dao popularity was classified as not popular.
We found that wink-dao 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.
Research
Socket uncovered npm malware campaign mimicking popular Node.js libraries and packages from other ecosystems; packages steal data and execute remote code.
Research
Socket's research uncovers three dangerous Go modules that contain obfuscated disk-wiping malware, threatening complete data loss.
Research
Socket uncovers malicious packages on PyPI using Gmail's SMTP protocol for command and control (C2) to exfiltrate data and execute commands.