How to use the rambdax.times function in rambdax

To help you get started, we’ve selected a few rambdax examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Nozbe / WatermelonDB / examples / web / src / models / generate.js View on Github external
const makeComments = (db, post, count) => times(i => makeComment(db, post, i), count)
github Nozbe / WatermelonDB / examples / web / src / models / generate.js View on Github external
db.action(async () => {
    await db.unsafeResetDatabase()
    const blogs = times(i => makeBlog(db, i), blogCount)
    const posts = flatMap(blog => makePosts(db, blog, fuzzCount(postsPerBlog)), blogs)
    const comments = flatMap(post => makeComments(db, post, fuzzCount(commentsPerPost)), posts)

    const allRecords = [...blogs, ...posts, ...comments]
    await db.batch(...allRecords)

    return allRecords.length
  })