test
This commit is contained in:
10
src/auth/drizzle/one.ts
Normal file
10
src/auth/drizzle/one.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { drizzle } from 'drizzle-orm/node-postgres';
|
||||
import { users } from './user.ts';
|
||||
import dotenv from 'dotenv';
|
||||
|
||||
dotenv.config();
|
||||
const db = drizzle(process.env.DATABASE_URL!);
|
||||
|
||||
const one = await db.select().from(users).limit(1);
|
||||
|
||||
console.log(one);
|
||||
42
src/auth/drizzle/user.ts
Normal file
42
src/auth/drizzle/user.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
import { pgTable, serial, text, varchar, uuid, boolean, jsonb, timestamp } from "drizzle-orm/pg-core";
|
||||
import { InferSelectModel, InferInsertModel } from "drizzle-orm";
|
||||
|
||||
export const users = pgTable('cf_user', {
|
||||
id: uuid('id').primaryKey().defaultRandom(),
|
||||
username: text('username').notNull().unique(),
|
||||
nickname: text('nickname'),
|
||||
password: text('password'),
|
||||
email: text('email'),
|
||||
avatar: text('avatar'),
|
||||
salt: text('salt'),
|
||||
description: text('description'),
|
||||
type: text('type').notNull().default('user'),
|
||||
owner: uuid('owner'),
|
||||
orgId: uuid('orgId'),
|
||||
needChangePassword: boolean('needChangePassword').notNull().default(false),
|
||||
data: jsonb('data').notNull().default({}),
|
||||
createdAt: timestamp('createdAt').notNull().defaultNow(),
|
||||
updatedAt: timestamp('updatedAt').notNull().defaultNow(),
|
||||
deletedAt: timestamp('deletedAt'),
|
||||
});
|
||||
|
||||
// 类型推断
|
||||
export type User = InferSelectModel<typeof users>;
|
||||
export type NewUser = InferInsertModel<typeof users>;
|
||||
|
||||
// 用户数据类型
|
||||
export type UserData = {
|
||||
orgs?: string[];
|
||||
wxUnionId?: string;
|
||||
phone?: string;
|
||||
};
|
||||
|
||||
// 用户类型枚举
|
||||
export enum UserTypes {
|
||||
user = 'user',
|
||||
org = 'org',
|
||||
visitor = 'visitor',
|
||||
}
|
||||
// export class User {
|
||||
|
||||
// }
|
||||
Reference in New Issue
Block a user