I could see similar question has been asked before and root cause was stuff like wrong spelling, collection name missing parent folder etc. But I have double checked everything and same error
here is relevant code line
wixData.query("Site Member").eq("_id", userId).find()
And I can see collection is there,
Please advise.
Found the answer already!
In the code I should be referring to it as “SiteMember”
I have the same problem with the Products collection de Wix-store ?
Here is my code :
/// Test de lecture des données :
let identif = $w ( ‘#identifiantProd’ ). text ;
console . log ( identif ); // OK
wixData . query ( “Products” ). eq ( “ID” , identif )
. find ()
. then ( ( results ) => {
console . log ( results . items );
} );
Thank you for your help
Yes thank you but you can’t do that on the products collection in wix-store.
It is best to add your own issue into a new post instead of bumping up an old post.
As stated in the documentation , you need to specify Stores/Products as the collection. Also, you need to use the field key (_id), and not the field name (ID). You want something like this:
wixData.query("Stores/Products").eq("_id",identif)
Ok for the general remark;
Thank you for this excellent clarification.
Thank you again for your answer,
With the following code I get the desired result.
In my results.items the content looks like this:
{
“_id”: “b7a0124e-a353-2811-2c28-4d70a4321e74”,
“_updatedDate”: “Tue Oct 26 2021 13:04:08 GMT + 0200 (Central European Daylight Saving Time)”,
“name”: “Bulletin of Ecclesiastical Literature n ° 484”,
“description”: "
Who is This? CXXI / 4
…
How can I display the value of the “name” field?
I tried “console.log (results.items [0] [3]);” but it does not work.
I did not find the answer in the documentation or I looked badly.
You want something like this:
wixData.query("Products").eq("ID",identif)
.find()
.then( (results) => {
let items = results.items;
let item = items[0];
let name = item.name;
console.log(name);
} );
These shortcuts should also work:
results.items[0]['name];
results.items[0].name;
This is a great answer to my problem.
Thank you 1000 times.