I try to create soft remove
library
Collection
import {Mongo} from 'meteor/mongo';
import SimpleSchema from 'simpl-schema';
const AccountTypes = new Mongo.Collection('acc_accountTypes');
AccountTypes.schema = new SimpleSchema({
code: {
type: String,
unique: true
},
name: {
type: String,
unique: true
},
nature: {
type: String,
allowedValues: ['Asset', 'Liability', 'Equity', 'Revenue', 'Expense']
},
status: {
type: String,
},
memo: {
type: String,
optional: true
}
});
AccountTypes.attachSchema(AccountTypes.schema);
export default AccountTypes;
Library
// Soft Remove
CollectionExtensions.addPrototype('softRemove', function (selector = {}) {
let self = this;
const schema = new SimpleSchema({
removed: Boolean,
removedAt: Date,
removedBy: String
});
self.attachSchema(schema, {selector: {type: 'softRemove'}});
return self.direct.update(
selector,
{
$set: {
// selector: {type: 'softRemove'}, // where to put this
removed: true,
removedAt: new Date(),
removedBy: Meteor.userId()
}
},
{multi: true},
(error, num) => {
if (num) {
console.log('soft remove');
}
}
);
});
Please help me