-
Notifications
You must be signed in to change notification settings - Fork 83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Array of files not working #80
Comments
Did you try the wildcard? (that's what I use and it's been working fine for a long time... I never had the need to specify only some files) sequelize_fixtures.loadFile('fixtures/*.json', models).then(() => {
// ...
}); this is my const chalk = require('chalk');
const fixtures = require('sequelize-fixtures');
const models = require('./../server/models');
const logger = require('./../server/utilities/logger');
// from file
module.exports = (callback) => {
fixtures
.loadFile('./initialization/fixtures/*.json', models)
.then(() => {
logger.log(chalk.green('Test data added to database'));
callback();
});
}; |
The wildcard does work, but the order the fixtures load in matters. Using the wildcard seems to use alphabetical order. So while the wildcard does work, it doesn't work for my case. await sequelize_fixtures.loadFile("fixtures/user.json", models);
await sequelize_fixtures.loadFile("fixtures/authentication.json", models); |
to solve that problem, I use
as file names, and I know they will always follow the order I set up to be. you can even name as
so in the future, you can have a file in between ... |
Sure, I personally don't think that's a very elegant way of solving the problem, but regardless the usage docs say this should work: //array of files
sequelize_fixtures.loadFiles(['fixtures/users.json', 'fixtures/data*.json'], models).then(function(){
doStuffAfterLoad();
}); and it hadn't been working for me. |
@Sorgrum I do prefer the file editing than edit all the time the function... :) |
Sure, so maybe we should just update the docs to reflect that passing in an array of files isn't a valid way to load fixtures? |
@Sorgrum can you raise a PR with a change to the README.md you feel is appropriate? Thanks! |
I'm trying to do this
sequelize_fixtures.loadFile(['fixtures/user.json', 'fixtures/authentication.json'], models).then(() => { ... }
But it results in the following error:
I get the same error if I include only one element in the array:
sequelize_fixtures.loadFile(['fixtures/user.json'], models).then(() => { ... }
but I don't get an error I load the same file not as an array:
sequelize_fixtures.loadFile('fixtures/user.json', models).then(() => { ... }
The text was updated successfully, but these errors were encountered: