updateOrCreate() is not working?

I see in this commit that have the function to update/Create:

But when i try to do this, i receive:

UserScreen.updateOrCreate is not a function

What i tried:

const UserScreen = use('App/Models/Base/UserScreen')
async updatePermissions ({ request, auth }) {

    let permissions = request.all()

      await UserScreen.updateOrCreate(permissions)
}
1 Like

I think you forgot to destructure request.all().
Also don’t forget that the updateOrCreate method allows only one set of record.

You code should read:

const UserScreen = use('App/Models/Base/UserScreen')
async updatePermissions ({ request, auth }) {

    let { permissions } = request.all()

      await UserScreen.updateOrCreate(permissions)
}

Linked commit is for v5. I don’t think it exists for v4

1 Like