andywer / andywer/squid

请提供一份针对mysql2/promise的例子

未关闭
#59 7 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
TypeScript
星标
157
派生
7
PR 合并指标
30 天内没有已合并 PR

描述

import { defineTable, Schema, NewTableRow, TableRow } from "squid"
import {} from 'mysql2/promise'
export type NewUserRecord = NewTableRow
const aTable = defineTable("a", {
id: Schema.Number,
name: Schema.String
})
// 没有使用过PostgreSQL。不喜欢使用纯sql字符串之外的sql查询,如下的database完全不认识
// export async function createUser(record: NewUserRecord): Promise {
// const { rows } = await database.query(sql`
// INSERT INTO users ${spreadInsert(record)} RETURNING *
// `)
// return rows[0]
// }

// export async function queryUserById(id: string): Promise {
// const { rows } = await database.query(sql`
// SELECT * FROM users WHERE id = ${id}
// `)
// return rows[0] || null
// }

贡献指南

这个仓库没有索引到贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。