Skip to content

Instantly share code, notes, and snippets.

@tomanagle
Created February 11, 2019 13:20
Show Gist options
  • Save tomanagle/ea044396d000d643ff513edbe629c1d3 to your computer and use it in GitHub Desktop.
Save tomanagle/ea044396d000d643ff513edbe629c1d3 to your computer and use it in GitHub Desktop.
import mongoose, { Schema, Document } from 'mongoose';
export interface IUser extends Document {
email: string;
firstName: string;
lastName: string;
}
const UserSchema: Schema = new Schema({
email: { type: String, required: true, unique: true },
firstName: { type: String, required: true },
lastName: { type: String, required: true }
});
// Export the model and return your IUser interface
export default mongoose.model<IUser>('User', UserSchema);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment