0

y'all,

Within my custom, strapi content type, controller code, what method in the model object do I use to create a new record? My app is configured to use MySql.

The following worked fine when I was using MongoDB, but now with MySql, it doesn't work.

With Mongo, in my code, I was doing this:

let model = strapi.models[modelName];
await model.create({"Name":"<NEW ENTRY>", "Path":ruleData.requestedPath});

, but now, with MySql, I get an error saying that model.create() is not a function.

Also, when I step into the code, create() is no longer there. I also can't seem to find the equivalent "create" method in the model object, for mysql.

??? Does the strapi ORM, model object change member functions, etc when moving from MongoDB to MySql??? I thought not since that was a big part of the reason for using the ORM.

Monico Moreno
  • 127
  • 1
  • 8

1 Answers1

0

I suggest you use strapi.query('article') instead of strapi.models.article

So it will be strapi.query('article').create({...})

Jim LAURIE
  • 3,859
  • 1
  • 11
  • 14