question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

update PivotModel update throws Error because doesn't have function _setUpdatedAt

See original GitHub issue

Hi guys! I have same problem as described in #203 I use update pivot model as documented

          await object
            .pictures()
            .pivotQuery()
            .where('picture_id', id)
            .update({ sort_order: index })

And this throws error “fakeModel._setUpdatedAt is not a function”

I’ve investigated code, and

  1. Crushed when calling update in https://github.com/adonisjs/adonis-lucid/blob/b613b648cf5cb6b582be716d3b775a9778fb0d2a/src/Lucid/QueryBuilder/index.js#L521

  2. pivotQuery creates PivotModel instance https://github.com/adonisjs/adonis-lucid/blob/7ed413824d858274290f57f3780e12b9bd819853/src/Lucid/Relations/BelongsToMany.js#L716-L727

  3. PivotModel class extends of BaseModel https://github.com/adonisjs/adonis-lucid/blob/b613b648cf5cb6b582be716d3b775a9778fb0d2a/src/Lucid/Model/PivotModel.js#L29

  4. BaseModel doesn’t have function _setUpdatedAt, this function exists only Model

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:14 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
RomainLanzcommented, Feb 22, 2020

Hey @rminossi!

In the meanwhile, you can directly use the Database class to update your fields.

Database.table('table')
  .where('x', x)
  .where('y', y)
  .update({ ... })
0reactions
stale[bot]commented, Nov 22, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Updating PivotTable requires updatedAtColumn #203 - GitHub
I don't use timestamps on both models, neither on pivot. When I try to update using model.relation().queryPivot().where().update() it throws an error saying:.
Read more >
Pivot Table Will Not Update Properly - Microsoft Community Hub
I have noticed that my pivot tables do not refresh with the most recent data once I: refresh the table, refresh the powerpivot,...
Read more >
Laravel Unknown Column 'updated_at' - Stack Overflow
In the model, write the below code; public $timestamps = false;. This would work. Explanation : By default laravel will expect created_at ...
Read more >
How to update PowerPivots when the underlying source data ...
Demonstration of how to update data in power pivots. Outlines when to update data or refresh data. Powerpivot is an addin for excel...
Read more >
How to Troubleshoot and Fix Excel Pivot Table Errors
A simple data change can cause a strange pivot table refresh error, if you added the pivot table data to the Data Model....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found