How to perform CRUD on new modules/service? #10824
-
Hi! I have gone through the tutorial etc. and am wondering how to actually use the CRUD operations which are specified here: https://docs.medusajs.com/learn/fundamentals/modules It says: "Your module's service extends a class generated by MedusaService from the Modules SDK. This class comes with generated methods for data-management Create, Read, Update, and Delete (CRUD) operations on each of your modules, saving your time that can be spent on building custom business logic."
But I am struggling how to use the .create part here? Or do I have it wrong? eg. if I am in workflows create-products and if I try to add a new line:
I get: What is the actual way we are meant to be accessing this so we can trigger the data to be updated when we create a new row? I am not actually trying to extend the Brand one, but instead add a new row when a new collection is created (a description and custom colours to the Collections page), but it is the same issue in both... I have spent a long time going through the doc's trying to figure out how to do this but its not helping and anything AI suggests I assume is using v1 as it doesn't work. Thanks in advance! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
All autogenerated methods from the async createBrands(...)
async listBrands(...)
async updateBrands(...)
// etc. Let me know if this helps :) |
Beta Was this translation helpful? Give feedback.
-
Thank you!! That helps :) |
Beta Was this translation helpful? Give feedback.
All autogenerated methods from the
MedusaService
follow the convention of:service.[method][Pluralized version of the model]
. For example, for your data modelBrand
, the methods are:Let me know if this helps :)