I've been using Retool for less than 24 hours, so sorry if this is a rookie error!
I am using the (new) Table element and have created a tags type column called "Teacher". The list of teachers is pulling from a query where the label is a friendly name, and the record ID is the value.
No records in the table are already tagged, so everything pulls up blank initially as expected. Once I tag the records, I created a trigger to update the corresponding records (MongoDB).
Issue is, I can't seem to figure out how to get the array of tag values out of the table and reference it in my query. All combinations of my attempt have resulted in "undefined". How do I reference the tags?
I hope my question is clear and I thank you in advance for any help!
Thank you so much for pointing out where to find the changed data. This leads to another point of confusion - how do I get this changed data into my MongoDB? Do I need to write a javascript function? Or is there a more straightforward way (please let there be!).
I have my table right now triggered to update on tag change, but I can change that to be a bulk 'save' update of all changed rows if one is better than the other as far as ease of implementation.
BTW, I did intend to use the 'tags' option as multiple teachers can be assigned to a particular record.
High level database structure:
Student Collection has an element called "teachers" which is an array of teacher ID's. The ID's correspond to a document in the Teacher Collection.
Random question - I can't seem to find how to put a placeholder text in the rows that do not have any tags. Something like "Select Tag". Right now, it is just a blank cell and you have to click around to trigger the drop down.
You do (for now) have to write some JavaScript to update the records in your MongoDB, but it shouldn't be too much more complicated that what you've written so far.
I'm admittedly not super familiar with the MongoDB resource connector, but I believe the quickest implementation would be to use the bulkWrite action type, and write some JavaScript to transform the changesetArray into a set of updates for MongoDB to perform. Something on these lines maybe:
Note that the records in changesetArray will include the primary key of the row, along with any changed values. You can change this if you need to reference other values on the record in the Advanced Interaction section:
I am early enough in the design/build that I just ended up doing away with MongoDB and trying out the Retool database instead. It is much easier to work with so thank you. I do have 'tag' working, but I wasn't able to get 'tags' (multiple teachers) to work as I wanted because I do not think Retool DB supports arrays just yet. Is this something that will be incorporated in the near future?
I have the placeholder configured as you suggested but still do not see it showing up when the tag column is null.