Any suggestions on how to gives access / query the database/collection for a normal user?
-------------------------------------------------------------------------------
I have a mysql db on google. I can see it in the database tab.
But access is fixed to Admin, I can not change that.
I can query my db as a Admin using the preview view.
But when I deploy a test site it dosent not work
I get the follwoing:
"Error: Error: Unable to handle the request. Contact the site administrator or view site monitoring logs for more information."
Running the code below gives me the permission error in the header. "Unable to handle the request. Contact the site administrator"
I followed this guide: https://www.wix.com/velo/forum/tips-tutorials-examples/tutorial-how-to-bypass-collection-permissions-and-hooks
code below:
------------------------------------------------------------------
I have moved my query to a db.jsw in backend
db.jsw
import wixData from 'wix-data';
export function searchAdress_back() {
return wixData.query("mysql/search_view")
find({suppressAuth: true})
.then( (results) => {
return results;
});
}
----------------------------------------------------------------------------
Mainpage main.js
import {searchAdress_back} from 'backend/db';
function searchAdress(params) {
let adress;
adress = $w('#addressInput1').value;
let lat = adress.location.latitude;
let long = adress.location.longitude;
// gethold of db data and querry
let db;
filteredResult = [] ;
tableSet = [];
searchAdress_back()
.then( (results)=> {
db =results;
console.log(db);
...
...
...
}).catch(e => {
console.log("Error query:")
console.log(e);
});
}
Solved: Needed to add a JSON permission file to my google cloud service
Example PERMISSIONS value:
{
"collectionPermissions": [
{
"id": "Contacts",
"read": ["Admin", "Member"],
"write": ["Admin"]
}
]
} https://support.wix.com/en/article/velo-integrate-your-google-cloud-mysql-or-postgres-database-with-your-wix-site