Could you explain me: Insert on Method
VS Insert on Client + Security
?
Which one better?
Ex:
1- Method
// Server
export const insertPost = new ValidatedMethod({
name: 'posts.insert',
mixins: [CallPromiseMixin],
validate: null,
run(doc) {
if (!this.isSimulation) {
return Posts.insert(doc);
}
}
});
-------------------
// client
insertPost.callPromise(this.form).then((result) => {
if (result) {
// success
}
}).catch((err) => {
// error
});
2- Allow insert in client with security package
// Server
Posts.permit('insert').ifLoggedIn().ifHasRole('postInsert').allowInClientCode();
-------
// Client
Posts.insert(this.form, (error, _id) => {
if (error) {
// error
} else {
// success
}
});