Socket
Socket
Sign inDemoInstall

adonis-lucid-update-or-create

Package Overview
Dependencies
0
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    adonis-lucid-update-or-create

Implements Laravel's updateOrCreate method as a trait in AdonisJs


Version published
Maintainers
1
Install size
1.91 kB
Created

Readme

Source

Installation

npm i adonis-lucid-update-or-create --save

Registering provider

Make sure to register the update or create provider inside start/app.js

const providers = [
  "adonis-lucid-update-or-create/providers/UpdateOrCreateProvider"
]

Usage

First add the trait to the model.

const Model = use("Model")

class Rating extends Model {
  static boot() {
    super.boot()

    this.addTrait("@provider:Lucid/UpdateOrCreate")
  }
}

Finally use the method as follows

const Rating = use("App/Models/Rating")

Rating.updateOrCreate(
  {
    user_id: 18,
    article_id: 23
  },
  { rating: 5 }
)

Keywords

FAQs

Last updated on 20 Oct 2018

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc