I am trying to sow a database using knex. With the help of a contributor, I successfully sowed one table where I need to take several steps:
- I need to derive id values from several external tables so that I can populate the foreign key values of the seed table.
- Create n entries in the seed table.
- Fill the table.
As already mentioned, this works for me for one table. Since I'm smarter than the roof, and I need to do almost the same thing for another table, I just copied what worked in the first seed file, fell into the second seed file, made a couple of suitable modifications (in particular, in the second table I need just fill in 1 value of the foreign key) and ... this will not work.
I'm at a loss. Surely there is some kind of stupid thing that I miss in this code, but I can not find it. I am trying to sow a table unitsthat I have to populate with a value properties.id.
exports.seed = function(knex, Promise) {
console.log('Seeding the %s table...', tableName);
Promise.resolve([
'properties',
])
.map(function(table) {
var ids = knex.select('id').from(table).pluck('id');
return ids;
})
.spread(function(properties) {
console.log('SPREADING UNITS');
});
};
What am I doing wrong? I dropped .catch()and .error()in this thing, but nothing is logged. Somehow, I never give up on a method .spread(...).
UPDATE
Whatever it costs, this is the contents of the method .mapuntil it returns ...
{ client:
{ Formatter: { [Function: Formatter_MySQL] super_: [Function: Formatter] },
Raw: { [Function: Raw_MySQL] super_: [Object] },
Transaction: { [Function: Transaction_MySQL] super_: [Object] },
QueryBuilder: { [Function: QueryBuilder_MySQL] super_: [Object] },
QueryCompiler: { [Function: QueryCompiler_MySQL] super_: [Function: QueryCompiler] },
migrationConfig: { tableName: 'knex_migration', directory: './migrations' },
seedConfig: { directory: './seeds' },
Runner: { [Function: Runner_MySQL] super_: [Function: Runner] },
connectionSettings:
{ host: '127.0.0.1',
port: '3306',
user: 'root',
password: '',
database: 'realster',
timezone: 'UTC',
charset: 'utf8',
debug: false },
Pool: { [Function: Pool_MySQL] super_: [Function: Pool] },
databaseName: 'realster',
pool: { client: [Circular], config: [Object], genericPool: [Object] },
_events: { start: [Function], query: [Function] },
Seeder: { [Function: Seeder_MySQL] super_: [Function: Seeder] } },
_single: { table: 'properties', pluck: 'id' },
_statements:
[ { grouping: 'columns', value: [Object] },
{ grouping: 'columns', type: 'pluck', value: 'id' } ],
_errors: [],
_joinFlag: 'inner',
_boolFlag: 'and',
_notFlag: false,
and: [Circular],
_method: 'pluck' }