Skip to content
Advertisement

strapi with mysql running simple raw sql

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.

Advertisement

Answer

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`;");
    });
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement