How to get the id property of a newly created object after save?

9 views
Skip to first unread message

Hudson C. Souza

unread,
Jul 8, 2015, 3:21:40 PM7/8/15
to ged...@googlegroups.com
GeddyVersion: 13.0.7
NodeVersion: 0.12.1

Hi.

I'm trying to access the Id property of an object within the save method of a model, but, it returns me an undefined error.

Example:

var campaign = Campaign.create({

    deviceId: 1,
    campaignTypeId: 1,
    campaignStatusId: 1,
    campaignPriorityId: 2,
    description: 'Testing stuff',
    sendBySatellite: false,
    file: null,
    data: '386690,386691,386692,386693,386694,386695,386696,386697,386698,386699,386700',

});

campaign.save(function(err, data) {
    
    // this returns undefined
    console.log(data.id)

});

Could someone help me, please? 

Thanks!
Reply all
Reply to author
Forward
0 new messages