Clean up the model
This commit is contained in:
parent
bfffd839a7
commit
e5a28b96ac
|
@ -91,21 +91,14 @@ function generateKey(hmacKey, algorithm, encoding) {
|
|||
return hmac.digest('base64');
|
||||
}
|
||||
|
||||
// var AuthenticationScheme = dataSource.define('AuthenticationScheme', AuthenticationSchemeSchema);
|
||||
// ApplicationSchema.authenticationSchemes = [AuthenticationScheme];
|
||||
|
||||
// var PushNotificationSetting = dataSource.define('PushNotificationSetting', PushNotificationSettingSchema);
|
||||
// ApplicationSchema.pushSettings = [PushNotificationSetting];
|
||||
|
||||
var Application = loopback.createModel('Application', ApplicationSchema);
|
||||
|
||||
// Application.hasMany(AuthenticationScheme, {as: 'authenticationSchemes', foreignKey: 'appId'});
|
||||
// Application.hasMany(PushNotificationSetting, {as: 'pushNotificationSettings', foreignKey: 'appId'});
|
||||
|
||||
/*!
|
||||
* A hook to generate keys before creation
|
||||
* @param next
|
||||
*/
|
||||
Application.beforeCreate = function (next) {
|
||||
// console.trace();
|
||||
var app = this;
|
||||
// use data argument to update object
|
||||
app.created = app.modified = new Date();
|
||||
app.id = generateKey('id', 'sha1');
|
||||
app.clientKey = generateKey('client');
|
||||
|
|
|
@ -1,26 +0,0 @@
|
|||
// See Device registration
|
||||
var InstallationSchema = {
|
||||
id: {
|
||||
type: String,
|
||||
required: true,
|
||||
id: 1
|
||||
},
|
||||
appId: String, // Application id
|
||||
appVersion: String, // Application version
|
||||
userId: String, // User id
|
||||
deviceToken: String, // Device token
|
||||
deviceType: String, // Device type, such as apns
|
||||
subscriptions: [String],
|
||||
|
||||
status: {type: String, default: 'active'}, // Status of the application, production/sandbox/disabled
|
||||
|
||||
// Timestamps
|
||||
created: {type: Date, default: Date},
|
||||
modified: {type: Date, default: Date}
|
||||
};
|
||||
|
||||
module.exports = function(dataSource) {
|
||||
dataSource = dataSource || new require('loopback-datasource-juggler').ModelBuilder();
|
||||
var Installation = dataSource.define('Installation', InstallationSchema);
|
||||
return Installation;
|
||||
}
|
Loading…
Reference in New Issue