Skip to content

Joe-noh/tane

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

72 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tane

Build Status

Tane means seeds.

# priv/repo/seeds.exs

use Tane

repo(MyApp.Repo)
|> model(MyApp.User)
|> seed(name: "Bob",  email: "[email protected]")
|> seed(name: "Mary", email: "[email protected]")

Then do this.

$ mix tane

You can specify the path.

$ mix tane --path priv/another_repo/seeds.exs

If you want to delete all data before seeding, delete_all!/1 is useful.

repo(MyApp.Repo)
|> model(MyApp.User)  # have to register these two before delete_all!.
|> delete_all!
|> seed(name: "Bob", email: "[email protected]")

Use registered/1 to get saved models.

use Tane

alias MyApp.User
alias MyApp.Post
alias MyApp.Repo

repo(Repo)
|> model(User)
|> seed(:bob, name: "bob")
|> seed(name: "mary")
|> model(Post)
|> seed(title: "Hello", body: "I'm bob", user_id: registered(:bob).id)

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages