Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to insert users username using simple schema for meteor

I'm trying to insert the logged in users username but whenever I submit the form. The collection never gets inserted. It only gets inserted if I comment out the createdBy field. I'm currently using the package User Accounts as my login/signin procedure

Here is my code:

createdBy: {
    type: String,
    autoValue: function() { 
        return this.field('username'); 
    }
},
createdAt: {
    type: Date,
    autoValue: function() {
        return new Date();
    }
}
like image 503
Mr.Bill Avatar asked Mar 14 '26 07:03

Mr.Bill


1 Answers

Never mind solved it here is what I had to put down. Hope it helps someone.

createdBy: {
        type: String,
        autoValue: function() {
            return Meteor.user().username
        }
    },
    createdAt: {
        type: Date,
        autoValue: function() {
            return new Date();
        }
    }
like image 147
Mr.Bill Avatar answered Mar 16 '26 23:03

Mr.Bill