rxdb-supabase icon indicating copy to clipboard operation
rxdb-supabase copied to clipboard

Error: ensureNotFalsy() is falsy in getSingleDocument

Open szsolutions opened this issue 1 year ago • 8 comments

Hi

I try to run the example according to the description, but I get an error when creating the replication: ensureNotFalsy() is falsy

The error occurs with the addConnectedStorageToCollection function, namely with getSingleDocument, which returns zero

async function addConnectedStorageToCollection(collection, storageCollectionName, schema) {
  var collectionNameWithVersion = _collectionNamePrimary(collection.name, collection.schema.jsonSchema);
  var collectionDocId = getPrimaryKeyOfInternalDocument(collectionNameWithVersion, INTERNAL_CONTEXT_COLLECTION);
  while (true) {
=>>>    var collectionDoc = await getSingleDocument(collection.database.internalStore, collectionDocId);
=>>>    var saveData = clone(ensureNotFalsy(collectionDoc));
    if (!saveData.data.connectedStorages) {
      saveData.data.connectedStorages = [];
    }
    var alreadyThere = saveData.data.connectedStorages.find((row) => row.collectionName === storageCollectionName && row.schema.version === schema.version);
    if (alreadyThere) {
      return;
    }

This rxdb function has apparently changed, but since version 14.15.1 is used in the project, the changes are not included.

https://github.com/pubkey/rxdb/commit/46f36368b58a9484f00145b85e61e4af21a85f06#diff-96872ef558a49d727431d58ca95d9fc2791e8b1727edfca0fcfdabac159b79c3R52

i just don't understand why this could have worked before? maybe i'm completely wrong

szsolutions avatar Jan 22 '24 20:01 szsolutions

Could you include the code that you're trying to run? Even better of course would be a minimal failing test case :)

Are you saying it's a bug in RxDB? Does the problem go away if you set an explicit RxDB version in your package.json?

marceljuenemann avatar Jan 22 '24 21:01 marceljuenemann

Thank you very much for your advice. It was really due to the different versions. if I use the rxdb version 14.15.1 in packing.json, it works!

szsolutions avatar Jan 23 '24 06:01 szsolutions

Are you sure you mean 14.15.1? Because that's the one in the package.json of this project already. If there is a bug that was fixed in a later version, I should probably bump versions and do another release

marceljuenemann avatar Jan 23 '24 10:01 marceljuenemann

Is it possible for you to release a version compatible with rxdb@15? There is a feature in 15 that I'd like to use, together with rxdb-supabase.

nukeop avatar Mar 26 '24 01:03 nukeop

I can confirm that downgrading to rxdb 14.15.1 works. Supporting v15 would be nice anyway.

mbeckenbach avatar Apr 27 '24 10:04 mbeckenbach

Is there going to be V15 support?

pulse-ventures avatar Jul 09 '24 12:07 pulse-ventures

Is there going to be V15 support?

I'll try to do a new release this month and clean up some issues and PRs

marceljuenemann avatar Jul 09 '24 22:07 marceljuenemann

I have created a gist that updates and fixes a number of things. You can use this TS file directly. I have also created a way to map your keys to your table columns. i.e. camelCase -> underscore_case. I think this also works with JSONB columns.

RXDB Supabase Replication

pulse-ventures avatar Jul 14 '24 12:07 pulse-ventures