maicmi
1
I have the insertion code on server side with forEach as following code:
Meteor.methods({
'upload': function upload(data, name) {
const wb = XLSX.read(data, {type:'binary'});
XLSX.utils.sheet_to_json(wb.Sheets[wb.SheetNames[0]]).forEach(r => Registers.insert(r));
return wb;
},
How can I insert more field? For example createdAt, owner, username
Should be as simple as this 
'upload': function upload(data, name) {
const wb = XLSX.read(data, {type:'binary'});
XLSX.utils.sheet_to_json(wb.Sheets[wb.SheetNames[0]]).forEach(r => {
r.createdAt = new Date()
r.owner = this.userId //(assuming it's the current logged in user)
r.username = Meteor.users.findOne(this.userId).username
Registers.insert(r))
}
return wb;
}
1 Like
maicmi
3
Thank you very much, herteby !!