import { Document, model, Schema } from 'mongoose'; import { Enum } from '../../library/enum'; export const Measurement = Enum( // Volume 'TEASPOON', 'TABLESPOON', 'DROP', 'FLUID_OUNCE', 'CUP', 'PINT', 'GALLON', 'MILILITER', 'LITER', // Weight 'OUNCE_WEIGHT', 'POUND', 'GRAM', // Other 'EACH', 'PERCENT', 'PIECE', 'RECIPE', 'AS_NEEDED' ); export type Measurement = Enum; export interface IngredientProps { /** The unit of measurement for this ingredient */ measurement?: Measurement; /** The name of the ingredient */ name?: string; /** A note, often describing perperation (choopped, drained, thawed, etc) */ note?: string; /** The required quantity of the ingredient, per the measurement unit */ quantity?: number; } export interface Ingredient extends IngredientProps, Document {} // Mongoose export const ingredientSchema = new Schema( { measurement: { type: String, default: Measurement.EACH }, name: { type: String, default: '' }, note: { type: String, default: '' }, quantity: { type: Number, default: 0, }, }, { _id: false } ); export const Ingredient = model('Ingredient', ingredientSchema);