I understand how you must feel. When I started with Wix Code half a year ago, I uttely hated it, it felt like I was swimming in deep water without a life jacket. Did not know much about Javascript, did not understand the model (pulling data in from client, instead of pushing html towards client), the database was an enigma, documentation was still sparse and the asynchronous paradigm, with Promises, oh, I loathed it.
But don´t give up. There is one way and only one way to master it: try. Read the Examples, try them out, study the API, read w3schools about Javascript, look for answers on Stackoverflow or on the Forum before you ask one and, above all, console.log is your friend. And then, if you have really tried out everything and can´t work it out, you come here and ask for help. Which I will try to give you now:
// … What does this data refer to? do i have to change it?
import wixData from ‘wix-data’;
Wix has seperated there logic into discrete parts. If you need to do anything with ‘users’ (login, passwords) you declare that you want to use that part of Wix in your code. That is called ‘import’. If you want to do anything with the database, you use, or import ‘wix-data’. Why do you have to do that? Why is not everything readily available? Answer: resources. If Wix has to load all this logic for every page and you only use 1 part of it. 90% of time and speed is waisted.
/ … How can I import data by entering the text box?
let query = wixData.query (“RedirectCode”);
Here, you are going to study. But I will give you a clue. Wix is event driven, like most develpment environments. That means nothing happens until a user or a function raises an event. In the case of a user, when he clicks something. SO you put in a text box, you add a button and when the button is clicked (event), you read the text (value) from the text box and do something with it. Good luck, there are enough examples of this.
// … How do you know what to look for to give me the result?
wixData.query ( “RedirectCode”)
.find ()
.then ((results) => {
let resultCount = results.totalCount; // 150
});
The Wix database (and, currently, any other db) is based on a query/queryresult paradigm. This means that you have rows in your collection, but when you want to do something with that data, you use a query, a question. Like: give me all rows where user = “AAA”, or where “date is greater then today”. Then, the database executes this query and returns a result, called a Resultset or QueryResult. Physically, this is a copy of a part of the db, with all rows that correpond to a query. So you act upon that copy, you never, ever work with the ‘real’ row in the database. You can only, thru the interface, add, update or delete .
So now you are going to read the API documentation on wix-data, the query object and the query result object and try out every example that you can find, until it becomes clear.
// … This data what does it charge? is it for?
import wixLocation from ‘wix-location’;
// … How do you know where to go, where?
wixLocation.to ( " http://wix.com ");
See ‘wix-data’, above. This is another discrete part of logic. So if you want to jump from location to location (URL), you load, import, that logic and work with it. BTW, all imports should be at the top of your code, one underneath the other, NEVER in a function.
Good luck, don´t give up, in a couple of months you will smile about the questions that you asked now.