These are chat archives for Automattic/mongoose

Aug 2016
Gabriele Cimato
Aug 20 2016 07:58
Hey guys I am fairly new to mongoose and mongoDb and I ran into what seems to be a silly problem
Gabriele Cimato
Aug 20 2016 08:03

I have a Schema like this:

import mongoose from 'mongoose';

const CategorySchema = mongoose.Schema({
  name: { type: String, required: true }
  code: { type: String }

module.exports = mongoose.model('category', CategorySchema);

which is quite straightforward, now I want to POST two categories with the same name and different code but I keep getting a duplicate error ... dup key: { : null, : null }, keep in mind that I drop the db every time I run the API locally so I start fresh, then I make the first POST and everything is ok, I make the second one with different code and I get that error, any hints ?

Gabriele Cimato
Aug 20 2016 18:09
nevermind just had to drop the db