The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

ajspeller (25) [Avatar] Offline
#1
After completing chapter 6 I began to test the API using Postman. I tried to create a review and got the message ...

{
    "name": "MongoError",
    "message": "Unknown modifier: $pushAll",
    "driver": true,
    "index": 0,
    "code": 9,
    "errmsg": "Unknown modifier: $pushAll"
}


After doing some research I found the following solution.

{
  usePushEach: true
}

I added this object to my locationSchema like so and then I was able to create new reviews.

const locationSchema = new mongoose.Schema({
  name: {
    type: String,
    required: true,
  },
  address: String,
  rating: {
    type: Number,
    'default': 0,
    min: 0,
    max: 5,
  },
  facilities: [String],
  coords: {
    type: [Number],
    index: '2dsphere'
  },
  openingTimes: [openingTimeSchema],
  reviews: [reviewSchema],
}, {
  usePushEach: true
});