Skip to content

Instantly share code, notes, and snippets.

@czbaker
Last active May 11, 2016 15:42
Show Gist options
  • Select an option

  • Save czbaker/c8376da8546f721bedbfb633b4d890ea to your computer and use it in GitHub Desktop.

Select an option

Save czbaker/c8376da8546f721bedbfb633b4d890ea to your computer and use it in GitHub Desktop.
import Mongoose, { Schema } from 'mongoose';
import Random from 'random-js';
// Random Interface
const r = new Random(Random.engines.mt19937().autoSeed());
// User Schema
const UserSchema = new Schema({
id: { type: String, required: true, default: r.string(20) },
username: { type: String, required: true },
email: { type: String, required: true, lowercase: true },
salt: { type: String, required: true },
password: { type: String, required: true },
roles: { type: [String], required: true },
});
export const User = Mongoose.model('User', UserSchema);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment