Wix Code database collections include permissions settings that let you control who can interact with the data in your collections. It's important to set these properly so that your site works the way you expect.
It's also important to remember that when you preview your site you are assigned the "Admin" role automatically. This means that you have full permissions on your data in preview. If things work in preview but not publish, check your permissions settings to make sure they are set properly for the other roles.
You can read more about permissions and roles here.