Here is a library that we are working on. Currently the first part of it works with the console log requested, but there is something not right with the function. Where are we going wrong? How can we get the output of the console log to give the requested information?
Databases between libraries are not shared, I.E. when the function is called it will look in the current projects database ID and not the Libraries project ID in order to resolve this issue you can
A:) force a request to the database using startWebRequest for the path /datablock_storage/:id/read_records?table_name=:name
this way you won’t need to re import a dataset on every new project you need the library for
B:) just import the project data from the library to the main project since the caller of the library is relying on the table to be on the main project if you move it there it will resolve it but will make it less convenient to use since it has a dependency that has to be manually added to actually use the library
Overall if your just starting I’d recommend Option B however do note that it is not within best practice to recommend this solution to be used. these paths for example allow you to access data from other projects which is what would eliminate having to re-install that database every time Option A is more ideal as it is more complex but more straightforward with users who’d wish to practically use it.
Perhaps an analogy would be better, when buying a table and the instruction manual isn’t included in the packaging! it’s frustrating not knowing how to put it together right? in this analogy you would be the person selling the table without the instructions and the buyer would be the user trying to make practical use of the table they had bought and wouldn’t be any issues when assembling it. making it clear to users that there are dependencies can mitigate it but is often discouraged if there’s a way to already have that information so that the user doesn’t have to spend more time fixing the library then their own project
Varrience
Varrience to the rescue again!
Thank you for the insight. The main issue with option a besides its complexity is that in the lesson, the students don’t have that as an option. They are supposed to follow what you have suggested as option b and import the specific data tables from the data library. They then import a library shared with them, test the library of functions that their classmates or I have created and give feedback on what needs to be fixed to make it more viable.
While someone with more experience coding would understand option a, unfortunately, it is difficult enough to get the students to follow simple directions as it is without spoon feeding or holding their hands. The goal is to teach them the skills so that they can learn from each other and on their own.
My main focus was to figure out what went wrong with the for loop function. The goal was to get the console log to output the string of the year and month of the first appearance of the requested character. The issue is that it is saying it is not found even though the table was imported and the first function with the request of a random character works. I need to figure out where we went wrong with the function requiring the for loop so that I can point out the specific issues and give hints as to solutions in hopes that this will get them thinking more critically and solve their own problems.
Thank you for your help in this and I appreciate the two options.
I got it to work with the console log tests. The if statement needed tweaking as well as the return.