Home > Back-end >  strapi with mysql running simple raw sql
strapi with mysql running simple raw sql

Time:10-23

Need to run this query in my test and unable to find the right syntax.

return strapi.connections.default.raw(`
            delete from nurses;
            delete from \`users-permissions_user\`;`);
    });

This is no postgresql and mysql does not like hyphens in table names. Please suggest.

CodePudding user response:

Simply don't use not allowed characters, it makes the life much more easy.

The backticks around the String, where implemented, so that theuser dind't need to escapee single and double quotes.

But for mysql you can use double quotes as long as you remember only to use single quotes for strings in you sql code

return strapi.connections.default.raw("
            delete from nurses;
            delete from `users-permissions_user`;");
    });
  • Related