collection
import SimpleSchema from 'simpl-schema';
ActionLogsFail = new Mongo.Collection('actionLogsFail');
let SchemaActionLogFail = new SimpleSchema({
"module":{
type:String,
index:true,
optional: true,
label:"Module Name"
},
"action":{
type:String,
index:true,
optional: true,
label:"Action Name"
},
"created_at":{
type: Date,
optional: true,
label: "Date Create added by system",
autoValue: function() {
if ( this.isInsert ) {
return new Date;
}
}
},
"ip_address":{
type: String,
label: "IP Address",
optional: true,
},
"detail":{
type: Object,
label: "Detail",
optional: true,
blackbox: true
}
});
ActionLogsFail.attachSchema(SchemaActionLogFail);
export default ActionLogsFail;
Methods
Meteor.methods({
'actionFail'(module,action,detail)
{
var ip = this.connection.clientAddress;
ActionLogsFail.insert({
module:module,
action:action,
detail:detail,
ip_address:ip,
created_at:new Date()
});
},
})
insert Data
{
module: 'Authentication',
action: 'Fail',
ip_address: '127.0.0.1',
created_at: 2020-06-13T06:49:11.037Z,
detail: {
email: 'test@test.com',
err: {
isClientSafe: true,
error: 403,
reason: 'Incorrect password',
message: 'Incorrect password [403]',
errorType: 'Meteor.Error'
}
}
Display Error
Exception while invoking method 'actionFail' Error: When the validation object contains mongo operators, you must set the modifier option to true
I20200613-13:49:11.165(7)? at doValidation (/project/node_modules/simpl-schema/dist/doValidation.js:64:11)
I20200613-13:49:11.165(7)? at ValidationContext.validate (/project/node_modules/simpl-schema/dist/ValidationContext.js:153:56)
I20200613-13:49:11.165(7)? at doValidate (packages/aldeed:collection2/collection2.js:426:33)
I20200613-13:49:11.165(7)? at Collection.Mongo.Collection.<computed> [as insert] (packages/aldeed:collection2/collection2.js:196:14)
Thank you.