Comments (9)
Sounds good, will add this to next build.
Edit: Actually not sure this would be possible. You'll have to use a callback
. In the next build, I'll add an app
and service
argument to be passed to callbacks, so you will be able to do this:
const cfg = {
path: 'users':
callback(user, seed, app, service) {
return service.patch(user._id, {
email: `user_${user._id}@myservice.com`
});
}
};
from feathers-seeder.
Ah, I see what you mean, index
is related to count
. I'll add that as well.
from feathers-seeder.
Wow what a quick response, respect :) I thought about implementing it myself, but wanted to first create a ticket.
Anyway, thx and yes {{index}} is just the iterator number of the count loop.
from feathers-seeder.
I think you could do this with template functions [#11] now:
let index = 0;
const counter = () => ++index;
const template = {
email: () => `user_${counter()}@myservice.com`
}
Give it a try and let us know.
from feathers-seeder.
Interestingly it works in this case.
path: 'users',
delete: false,
randomize: false,
templates: [{
id: counter(),
group: 'user',
email: '[email protected]',
birthday: 1990,
password: 'test123'
}, {
id: counter(),
group: 'user',
email: '{{internet.email}}',
birthday: 1990,
password: 'test123'
}],
but not in this case:
path: 'users',
count: 3,
delete: false,
template: {
id: counter(),
group: 'user',
email: '{{internet.email}}',
birthday: () => Math.floor(Math.random() * 100) + 1900,
gender: '{{random.boolean}}',
password: 'test123'
Here it is always the same value.
from feathers-seeder.
It's because you passed the result of a function call.
Use counter
or an arrow function per the example.
from feathers-seeder.
i'm silly, sry you're right. Just strange that it worked in the above example.
from feathers-seeder.
So, can this issue be closed?
from feathers-seeder.
Well to be honest it can still be improved, just using {{index}} would be really great, but as a workaround this is legitimate. Maybe referecing this in the documentation at least.
from feathers-seeder.
Related Issues (19)
- Seeder works on "services" and not "models" HOT 2
- enabling https HOT 3
- Error on postinstall (Unknown plugin "add-module-exports") HOT 2
- question: creating users from predefined data HOT 1
- bug: number types in templates are empty HOT 1
- Import data 1:1 without randomization HOT 4
- executing order of service array HOT 4
- Reset autoincrement value for sequelize-adapter HOT 4
- 1.0.8 not working anymore HOT 1
- support faker locale option HOT 3
- How to handle several dependent seeds HOT 3
- Seeder not working with nuxt-js project HOT 4
- MIT License HOT 11
- GeneralError: Cannot read property 'remove' of undefined HOT 1
- Getting dates in ISO format
- ResourceRequest timed out HOT 3
- Low Severe Vulnerabilities Found
- error: MethodNotAllowed: Can not remove multiple entries HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from feathers-seeder.