[GH-ISSUE #207] When using "mutations" with a subscription it's throwing a warning #98

Closed
opened 2026-05-23 08:30:27 -06:00 by gitea-mirror · 5 comments
Owner

Originally created by @diogomartino on GitHub (Mar 11, 2023).
Original GitHub issue: https://github.com/appy-one/acebase/issues/207

Originally assigned to: @appy-one on GitHub.

Hi! First of all, thanks for your work, this lib is awesome. I'm using NodeJS v18.7.0 with AceBase 1.27.0.

I'm trying to execute something when some specific props of an object change, and I'm trying to use subscriptions for this. But, while using code from the documentation, it's throwing a warning in the console:

  db.ref(`messages/${message.id}`).on('mutations', (snapshots) => {
    snapshots.forEach((snapshot) => {
      console.log('snapshot', snapshot.val());
    });
  });

It's throwing:
Unless you know what you are doing, it is best not to use the value of a mutations snapshot directly. Use child methods and forEach to iterate the mutations instead

What am I doing wrong? The lack of examples when using the "mutations" is making me quite confused, if that part could be improved it would be great.

Thanks!

Originally created by @diogomartino on GitHub (Mar 11, 2023). Original GitHub issue: https://github.com/appy-one/acebase/issues/207 Originally assigned to: @appy-one on GitHub. Hi! First of all, thanks for your work, this lib is awesome. I'm using NodeJS `v18.7.0` with AceBase `1.27.0`. I'm trying to execute something when some specific props of an object change, and I'm trying to use subscriptions for this. But, while using code from the documentation, it's throwing a warning in the console: ```javascript db.ref(`messages/${message.id}`).on('mutations', (snapshots) => { snapshots.forEach((snapshot) => { console.log('snapshot', snapshot.val()); }); }); ``` It's throwing: `Unless you know what you are doing, it is best not to use the value of a mutations snapshot directly. Use child methods and forEach to iterate the mutations instead` What am I doing wrong? The lack of examples when using the "mutations" is making me quite confused, if that part could be improved it would be great. Thanks!
gitea-mirror 2026-05-23 08:30:27 -06:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@appy-one commented on GitHub (Mar 13, 2023):

Hi @diogomartino, thanks for reporting this. Kindly note that it is NOT throwing anything, it only logs a warning message to the console. In your case, it should not do this (you are using forEach so that should be good). I checked the code and think I found the issue, I'll fix it asap!

<!-- gh-comment-id:1466356098 --> @appy-one commented on GitHub (Mar 13, 2023): Hi @diogomartino, thanks for reporting this. Kindly note that it is NOT throwing anything, it only logs a warning message to the console. In your case, it should not do this (you are using `forEach` so that should be good). I checked the code and think I found the issue, I'll fix it asap!
Author
Owner

@diogomartino commented on GitHub (Mar 13, 2023):

Oh yes, I meant throwing as like a logging term, not like throwing an exception, you are correct. Thanks for seeing this 👍

<!-- gh-comment-id:1466677694 --> @diogomartino commented on GitHub (Mar 13, 2023): Oh yes, I meant throwing as like a logging term, not like throwing an exception, you are correct. Thanks for seeing this 👍
Author
Owner

@appy-one commented on GitHub (Apr 11, 2023):

@diogomartino I fixed this in acebase-core v1.26.1, I'll publish a new acebase package shortly

<!-- gh-comment-id:1503895337 --> @appy-one commented on GitHub (Apr 11, 2023): @diogomartino I fixed this in `acebase-core` v1.26.1, I'll publish a new `acebase` package shortly
Author
Owner

@appy-one commented on GitHub (Apr 11, 2023):

@diogomartino Fix has been published in https://github.com/appy-one/acebase/releases/tag/v1.28.0

Sponsor AceBase Spread the word contribute

<!-- gh-comment-id:1503966044 --> @appy-one commented on GitHub (Apr 11, 2023): @diogomartino Fix has been published in https://github.com/appy-one/acebase/releases/tag/v1.28.0 [![Sponsor AceBase](https://user-images.githubusercontent.com/26569719/168233053-8e56b243-4140-40ab-9a30-4cb3cc149bfe.svg)](https://github.com/sponsors/appy-one) [![Spread the word](https://user-images.githubusercontent.com/26569719/169265089-3d593555-e1ad-4390-986b-877ac2c38a47.svg)](https://twitter.com/intent/tweet?button=&url=https://github.com/appy-one/acebase&text=I'm+using+@AcebaseRealtime+in+my+project+to+make+my+life+easier!&button=) [![contribute](https://user-images.githubusercontent.com/26569719/169265318-30c4c6a5-7c89-46a0-a7a2-ef433a8192f4.svg)](https://github.com/appy-one/acebase#contributing)
Author
Owner

@diogomartino commented on GitHub (Apr 15, 2023):

Thank you🙏

<!-- gh-comment-id:1509473280 --> @diogomartino commented on GitHub (Apr 15, 2023): Thank you🙏
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/acebase#98
No description provided.