js401-reading

Class 04 Reading - Advanced Mongo/Mongoose

testing mongo

const productSchema = new mongoose.Schema({
  name: { type: String, required: true},
  price: { type: Number, required: true},
  description: {type: String},
});
<export>
<import productModel>
module.exports.create = async (product) => {
  if (!product)
    throw new Error('Missing product');
    await productModel.create(product);
}
"scripts": {
  "test": "jest --runInBand ./test"
}
"jest": {
    "testEnvironment": "node"
}

interfaces and repositories