Files
medusa-store/packages/medusa/src/models/user.ts
Sebastian Rindom 8edb32c742 docs: oas (#197)
Adds OpenAPI specification of Storefront and Admin APIs.
Updates docs project.
2021-03-10 11:51:54 +01:00

84 lines
1.6 KiB
TypeScript

import {
Entity,
BeforeInsert,
CreateDateColumn,
UpdateDateColumn,
DeleteDateColumn,
Index,
Column,
PrimaryColumn,
} from "typeorm"
import { ulid } from "ulid"
@Entity()
export class User {
@PrimaryColumn()
id: string
@Index({ unique: true })
@Column()
email: string
@Column({ nullable: true })
first_name: string
@Column({ nullable: true })
last_name: string
@Column()
password_hash: string
@Column({ nullable: true })
api_token: string
@CreateDateColumn({ type: "timestamptz" })
created_at: Date
@UpdateDateColumn({ type: "timestamptz" })
updated_at: Date
@DeleteDateColumn({ type: "timestamptz" })
deleted_at: Date
@Column({ type: "jsonb", nullable: true })
metadata: any
@BeforeInsert()
private beforeInsert() {
if (this.id) return
const id = ulid()
this.id = `usr_${id}`
}
}
/**
* @schema user
* title: "User"
* description: "Represents a User who can manage store settings."
* x-resourceId: user
* properties:
* id:
* description: "The unique id of the User. This will be prefixed with `usr_`"
* type: string
* email:
* description: "The email of the User"
* type: string
* first_name:
* type: string
* last_name:
* description: "The Customer's billing address."
* anyOf:
* - $ref: "#/components/schemas/address"
* created_at:
* type: string
* format: date-time
* updated_at:
* type: string
* format: date-time
* deleted_at:
* type: string
* format: date-time
* metadata:
* type: object
*/