Query database getItem() issue

Hi all,

I wrote a code to get all the user’s inputs from two different pages and save them in mydataset1. Now I am trying to cross match the user’s inputs from mydataset1 with the information in mydataset2 and return a result from keyJ of mydataset2 for the match. For the way it is set up, any selection made in the form corresponds to a unique combination in mydataest2.

When the code is run, all the inputs in the from are saved correctly in mydataset1 but when I try to query mydataset2 using eq() and session.getItem() functions based on the user’s selection saved in mydataset1, it works for all my inputs apart from one.

I first tested it manually by selecting a specific combination of inputs in the form and inputting the corresponding values (e.g. 5, 5, 2.7, etc. - see sample test code at the end) of the user’s inputs in the query instead of using the session.getItem() function to test the code. This worked perfectly and returned the correct result from keyJ of mydataset2.

Then, I replaced each value in the query with session.getItem(“keyX”).value and this works for all of the inputs apart from one, session.getItem(“key1”).value.
If I replace this input with the corresponding value (e.g. 5) the code works and returns a unique result from keyJ from mydataset2, if I use session.getItem(“key1”).value for this input it returns multiple results from keyJ in mydataset2.
I “printed” the session.getItem(“key1”).value using console.log and it shows the correct number (e.g. 5) . Both fields (key1 and keyA) in both datasets are set up as type number.

I don’t understand why this works for all the inputs in the query apart from one and where the error is.

The code I am using on the last page of my form is shown below.

Thanks for your help

//-------------PAGE 3-------------//
//-------------Imports-------------//
import wixData from 'wix-data';
import wixLocation from 'wix-location';
import {session} from 'wix-storage';

//-------------Submission From Selection to mydataset1-------------//
export async function button1_click(event) {

let toInsert = {
 "formId": session.getItem("formId"),
 "key1": session.getItem("key1"),
 "key2": session.getItem("key2"),
 "key3": session.getItem("key3"),
 "key4": session.getItem("key4"),
 "key5": session.getItem("key5"),
 "key6": session.getItem("key6"),
 "key7": session.getItem("key7"),
 "key8": session.getItem("key8"),
 "key9": session.getItem("key9"),
 "key10": session.getItem("key10"),
 "key11": session.getItem("key11"),
 "key12": session.getItem("key12"),
 "key13": session.getItem("key13"),
 "key14": session.getItem("key14"),
 "key15": session.getItem("key15"),
 "key16": session.getItem("key16"),
    };

wixData.insert("mydataset1", toInsert)
    .then( (results) => {
 let item = results;
    } )
    .catch( (err) => {
 let errorMsg = err;
    } );

//-------------Query mydataset2 with selection from form saved in mydataset1-------------//
await wixData.query("mydataset2")
.eq("keyA", session.getItem("key1").value) //this input does not work 
.eq("keyB", session.getItem("key2").value)
.eq("keyC", session.getItem("key3").value)
.eq("keyD", session.getItem("key4").value)
.eq("keyE", session.getItem("key5").value)
.eq("keyF", session.getItem("key6").value)
.eq("keyG", session.getItem("key7").value)
.eq("keyH", session.getItem("key8").value)
.eq("keyI", session.getItem("key9").value)
.find()
.then( (results) => {
 if(results.items.length === 1) {
 $w("#textresult").text = results.items[0].keyJ.toString(); // get result value
    } else {
 $w("#textresult").text = "Something went wrong with your selection :/" 
 $w("#textresultsnumber").text = results.totalCount.toString() //check n results returned 
    }
} )
.catch( (err) => {
 let errorMsg = err;
} );

wixLocation.to("/page3#anchor1");
}

//-------------Test Code-------------//
//await wixData.query("mydataset2")
//.eq("keyA", 5) //this input does not work 
//.eq("keyB", 5)
//.eq("keyC", 2.7)
//.eq("keyD", 180)
//.eq("keyE", 0.3)
//.eq("keyF", 0.5)
//.eq("keyG", 0.2)
//.eq("keyH", 0)
//.eq("keyI", 0)
//.find()
//.then( (results) => {
//    if(results.items.length == 1) {
//    $w("#textresult").text = results.items[0].keyJ.toString(); // get result value
//    } else {
//    $w("#textresult").text = "Something went wrong with your selection :/"  
//    $w("#textresultsnumber").text = results.totalCount.toString() //check n results returned 
//   }
//} )
//.catch( (err) => {
//    let errorMsg = err;
//} );

//wixLocation.to("/page3#anchor1");
//}