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.

Unable to persist create records using Loki as adapter

See original GitHub issue

I have added watermelondb + Loki to a project and when creating records the raw values are all the default values of empty strings and 0 numbers. When I log out the records during the batch creation they are there but upon retrieval the raw values are the defaults.

When writing directly to the raw field it does persist, ie: lpEvent._raw.block_number

Here is the actual create action in the repo branch: https://github.com/status-im/liquid-funding/blob/watermelon-data-persist/app/actions/lpEvents.js#L19

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
bgitscommented, Jan 17, 2019

It seems using a decorator on a class property is simply ignored by babel for some reason.

I got it to work using this approach:

function initialize(target, name, descriptor) {
  descriptor.initializer = true
}

export default class LpEvent extends Model {

  static table = 'lp_events'
  
  @field('address')
  @initialize
  address() {}
}

By declaring it as a method babel no longer discards it, and I had to create the initialize decorator in order to get around this invariant: https://github.com/Nozbe/WatermelonDB/blob/master/src/decorators/common.js#L21-L25

Which leads me to ask, why is that invariant needed?

0reactions
bgitscommented, Jan 17, 2019

I believe I found the issue. I think it’s related to: https://github.com/babel/babel/issues/8417

Here is the fix in my webpack config: https://github.com/status-im/liquid-funding/commit/2bc3e5fd3426bd91ee8d70e2d43b9ce11e370299

Read more comments on GitHub >

github_iconTop Results From Across the Web

Troubleshooting | Grafana Loki documentation
This error can appear in Grafana when Grafana Loki is added as a datasource, indicating that Grafana in unable to connect to Loki....
Read more >
Unable to loadDatabase with lokiJs - Stack Overflow
I have trying to create a database with a collection added to this database and the changes saved to a IndexedDB. Two controllers...
Read more >
Logging with the LokiStack | OpenShift Container Platform 4.10
LokiStack's proxy uses OpenShift Container Platform authentication to enforce multi-tenancy. Loki refers to the log store as either the individual component or ...
Read more >
error running loki err=invalid database\nerror creating index ...
As a workaround we always have to delete all folders named "index_#" (mentioned in the log) in the storage and then restart loki-0...
Read more >
Structured logging in Elixir using Loki - Alex Koutmos
And finally we'll set up a simple Phoenix application backed by Postgres and run Loki along side it to collect all of our...
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