const mongoose = require('mongoose').set('debug', false)
const Schema = mongoose.Schema;

mongoose.Promise = global.Promise;
mongoose.level = "F";

const { ObjectId } = require('mongodb');

// Resolving error Unknown modifier: $pushAll
mongoose.plugin(schema => {
  schema.options.usePushEach = true
});


const SubscriberSchema = new Schema({
  endpoint: String,
  keys: Schema.Types.Mixed,
  userId: String,
  access: String,
  browser: String,
  browser_random: String,
  createDate: {
    type: Date,
    default: Date.now
  }
});

var Subscription = module.exports = mongoose.model('subscribers', SubscriberSchema);

Subscription.createIndexes()
  .then(() => { })
  .catch((err) => { throw err; });

