Skip to content

Instantly share code, notes, and snippets.

@hoangsetup
Last active September 18, 2021 07:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hoangsetup/fe553e6870e94c9dea077a629e68d3eb to your computer and use it in GitHub Desktop.
Save hoangsetup/fe553e6870e94c9dea077a629e68d3eb to your computer and use it in GitHub Desktop.
// src/models/customer.model.ts
import { Schema, Model, model } from 'mongoose';
export interface ICustomer {
name: string;
phoneNumber: string;
}
const CustomerSchema = new Schema<ICustomer, Model<ICustomer>, ICustomer>({
name: {
type: String,
required: true,
},
phoneNumber: {
type: String,
required: true,
unique: true,
},
});
const CustomerModel = model<ICustomer>('Customer', CustomerSchema, 'customers');
export default CustomerModel;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment