When adding categories to an Acronym, on duplicate requests, attach creates duplicate references. Is there a way to check if it is already attached before making an attach call? I tries isAttached() with no luck.
You can do a filter in the database - AcronymCategoryPivot.query(on: req).filter(\.acronymID == acronym.requireID()).filter(\.categoryID == category.requireID()).first() to see if that returns anything.
The other option is set up a dual key in the database, but that’s more involved and IIRC requires dropping down to raw SQL
Ah awesome, if that works that’s great (I’d still leave in the references). The only things to consider with that approach (which is the dual key in the database) is that you might want to catch the error if the users tries to create it, but it’s up to you