Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
sails-seed
Advanced tools
npm install sails-seed
Depending on you version of sails, sails-seed is treated differently On install, a config/seeds.js is created. Here you will put your seeding data.
For Sails 0.11 and greater there is nothing further to do. Sails-seed runs as an installable hook.
For Sails 0.10 and previous, a file of api/hook/seed/index.js is created on installation. No further configuration is required, but this file is necessary for the data to seed.
Place your seeding data in the config/seeds.js file. For exampe, for a Person model, your config/seeds.js file might look like
module.exports.seeds = {
person: [
{
firstName: 'Luke',
lastName: 'Skywalker'
},
{
firstName: 'Darth',
lastName: 'Vader'
}
]
}
By default, sails-seed will not overwrite the data which is present. If you would not like your seed to overwrite, your new config/seeds.js file might look like
module.exports.seeds = {
person: {
data: [
{
firstName: 'Luke',
lastName: 'Skywalker'
},
{
firstName: 'Darth',
lastName: 'Vader'
}
],
overwrite: false
}
}
If you would like to seed only data that is not presetnt, you can use a unique field(s), like so
module.exports.seeds = {
person: {
data: [
{
firstName: 'Luke',
lastName: 'Skywalker'
},
{
firstName: 'Darth',
lastName: 'Vader'
}
],
unique: ['lastName', 'firstName']
}
}
This will only create objects that do not have the unique firstName and lastName combinations Given an overwrite true option, sails-seed will only overwrite items which match the unique requirements.
If you would like disable the seed hook (say for testing purposes) simply add the following config option
module.exports.seeds = {
disable: true,
person: {
data: [
{
firstName: 'Luke',
lastName: 'Skywalker'
},
{
firstName: 'Darth',
lastName: 'Vader'
}
],
unique: ['lastName', 'firstName']
}
}
If you would like to disable per model, you can add an active option. Like so will disable the person seeding
module.exports.seeds = {
person: {
active: false,
data: [
{
firstName: 'Luke',
lastName: 'Skywalker'
},
{
firstName: 'Darth',
lastName: 'Vader'
}
],
unique: ['lastName', 'firstName']
}
}
You may also set configurations (say for testing) via the sails pipeline. Just make sure that you have set the configurations you wish you have before the hook:moduleloader:loaded event. This way you wouldn't have to change your configuration for testing in the code, and could have the test configuration.
All New Enhancements and development are branched of develop. Pull requests for enhancements should be added to develop. The current version that is published is master. Any bug fixes and bug pull requests will be added to the current release branch. That is, if version 1.4.x is released on master, then any bug fixes or bug pull requests should be added to the branch v1.4. After merge and ready to release, a patch version of the v1.4 branch would be merged to master and released. Once develop has gotten enough features, a new release branch will be created and merged to master.
M. Elliot Frost, CEO of Frostware
FAQs
Simple data seeding for sails.js projects.
The npm package sails-seed receives a total of 55 weekly downloads. As such, sails-seed popularity was classified as not popular.
We found that sails-seed demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.