Problem updating database

I’m writing code to deal with ‘likes’, which involves adding the new like to fields on two databases. One of these, #dynamicDatasetupdates updates correctly but the other, #dataset2 doesn’t.

I access the correct file on dataset2 with this code:

$w ( “#dataset2” ). setFilter ( wixData . filter ()
. contains ( “email” , email ))
. then ( () => {
$w ( ‘#imageAuthor’ ). show ();
})

It finds the right file because the correct image is displayed. The dataset is set to read-write.

Here is the code to update both the databases:

// add or remove a like
export function buttonClicked_click () {
let itemObj1 = $w ( “#dynamicDataset” ). getCurrentItem ();
let itemObj2 = $w ( “#dataset2” ). getCurrentItem ();
bookID = itemObj1 . _id ;
likesDB1 = itemObj1 . likes ;
likesDB2 = itemObj2 . likes ;

**if**  ( liked  ===  0 ) 
   {         
    **let**  plusLikes1  =  itemObj1 . likes  +  1 ; 
    **let**  plusLikes2  =  itemObj2 . likes  +  1 ; 
    $w ( "#dynamicDataset" ). setFieldValue ( 'likes' ,  plusLikes1 );  
    $w ( "#dynamicDataset" ). save (); 
    $w ( "#dataset2" ). setFieldValue ( 'likes' ,  plusLikes2 );  
    $w ( "#dataset2" ). save (); 
    $w ( "#heart" ). show (); 
    liked  =  1 ; 
            } 

As I said, #dynamicDataset works fine and the heart symbol shows, but #dataset2 doesn’t save the value. Strangely, I put a text field on the page connected to the likes field on the database and this changes correctly when the like button is clicked - I would have thought that means the database has been updated, as it’s picking up the new value from there - isn’t it?

Can someone help me untangle this?

UPDATE:
I find that the database can be updated when I am logged in as the owner of the file being updated (identified by email).
Obviously, I want anybody to be able to ‘like’ a file and I wasn’t aware only the ‘owner’ can update it. Is there a way around this?

PROBLEM SOLVED!!!
Changed the settings of the database to allow ‘anyone’ to update it.

Phew! It was driving me mad. Hope this helps somebody in the future.

@ic_forrest
If you can update as ADMIN but not as remember, it will be a permission issue.

Do a test and set your DB-permission to EVERYONE.

Look also for db-OPTIONS in the VELO-APIs

Ok i was too late with my answer.
How ever you do not need to open your DB for everyone just to let it work again😉