Skip to content

Instantly share code, notes, and snippets.

@weixiyen
Created January 2, 2018 21:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save weixiyen/63428b18085141dc15527f49946dccf5 to your computer and use it in GitHub Desktop.
Save weixiyen/63428b18085141dc15527f49946dccf5 to your computer and use it in GitHub Desktop.
User
|> prepared(user_id: user_id, username: username)
|> insert(user_id: :user_id, username: :username)
|> if_not_exists
|> User.save
User
|> update(username: username)
|> where(user_id: user_id)
|> constrain(username: previous_username)
|> User.save
User
|> prepared(user_id: user_id)
|> delete(:all) # here :all refers to all fields
|> where(user_id: :user_id)
|> User.del
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment