summaryrefslogtreecommitdiff
path: root/examples/lib/okpush/db.js
blob: 5a66b014b7d3c878e7a0cafac183001c9220c5dc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// db

function init (config) {
  var db = mongoose.connect(config.mongodbUrl);
  mongoose.connection.on('error', errorHandler);

  var pushAssociationSchema = new db.Schema({
    user: {
      type: 'String',
      required: true
    },
    type: {
      type: 'String',
      required: true,
      enum: ['ios', 'android'],
      lowercase: true
    },
    token: {
      type: 'String',
      required: true
    }
  });

  PushAssociation = db.model('PushAssociation', pushAssociationSchema);
}

function errorHandler (error) {
    console.error('ERROR: ' + error);
};