Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

seeding not getting data back

I am trying to seed, save in users then get the userId and insert into account table:

exports.seed = function(knex, Promise) {
  return Promise.join(
    // Deletes ALL existing entries
    knex('users').del(), 
    knex('accounts').del(),

    // Inserts seed entries
    knex('users').insert({
        uerId: '1231231',
        email: '[email protected]'
    }).then(function(result){
      knex('accounts').insert({
        accountId: '0',
        userId: result[0].userId
      });
    })
  );
};

But the problem is the result getting is the inserted rows value? How can I get back the data?

like image 241
Alvin Avatar asked Oct 31 '22 15:10

Alvin


1 Answers

I think you have a typo here: accountId: ''0', remove double '' before the zero

like image 141
uglycode Avatar answered Jan 04 '23 14:01

uglycode