Insert/Remove from arrays in dataset

hi. Instead of me giving a 10 paragraph explanation of my entire goal and issues… here’s what I am having trouble with:

Test dataset:

I want to test an input value (from a customer) against values in the ‘active’ array shown above. If the password they input matches, then logic tests their numeric input against the array filled with numbers. That’s fine and dandy.

My question:
When a customer successfully matches the password & active integer value… i want to remove the particular value from the integer array, ‘active’, and add it to the integer array, ‘used’.

I’ve done a bit of searching sifting through wix’s documentation… I’ve seen insert/remove/etc, but writing to an array field… how???

//function insertReference (collectionName: propertyName: referringItem: Object | string, referencedItem: Object | string | Array| Array)
pulled from Corvid API Reference

//wixData.insertReference(“qrdotd”, “used”, entryID, certificateInput)
entryID is a string and certificateInput is an integer

So at this point, it’s obvious I can insert an array of any type into the dataset, but I have not yet been successful… My only thought and idea would be to redefine the string entirely instead of trying to insert individual integers?

Any ideas? Cheers

The question is not so clear. Please explain with examples.

Sorry.

I have two array fields in the dataset. One is populated and one is empty.

How do I take a value from the first array field and programmatically move it to the other array field?

ex:

let array1 = results.item[x].active;
let value = array1[2]; //27
???

How can I programmatically move 27 from the “active” array field to the “used” array field?

First you retrieve the record (either by get() or by .query() ).
then:

wixData.get("collectionName", "assdsd-dfdf-dfdf"/*id of the record*/)
.then(r => 
let valueToReplace = 27;
let newActiveArr = r.active.filter(e => e !== valueToReplace);
if(newActiveArr.length <  r.active.length){
r.active = newActiveArr ;
r.used.push(valueToReplace);
wixData.update("collectionName", r);
}
})