Closed dip-sinha closed 4 years ago
[RepositoryNameHere].execute()
is the command to write native SQL queries.
can anyone explain how to connect native sql in loopback 4
@Rojasivalingam use Repository.execute()
eg:
userRepository.execute(
'SELECT * from User WHERE name=? && id=?',
['Apple', 3]
);
The returned object is the the result object of https://www.npmjs.com/package/mysql, you will have to process it on your own.
Actually , I wants to know about the execution of the query in detail . I'm new to loopback so any help is appreciated
On Wed, Oct 7, 2020 at 7:29 PM Hage Yaapa notifications@github.com wrote:
@Rojasivalingam https://github.com/Rojasivalingam use Repository.execute() eg:
userRepository.execute( 'SELECT * from User WHERE name=? && id=?', ['Apple', 3]);
The returned object is the the result object of https://www.npmjs.com/package/mysql, you will have to process it on your own.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/strongloop/loopback-next/issues/4869#issuecomment-704955756, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQYR57TBA23Y5OYJK27HHS3SJRX5TANCNFSM4LGLMYWQ .
Create a LoopBack project using the lb4
command, you can access the repository in the controller, where you can specify the SQL command as I have shown. Start here.
yeah...!! Thanks anyways
On Thu, Oct 8, 2020 at 3:33 PM Hage Yaapa notifications@github.com wrote:
Create a LoopBack project using the lb4 command, you can access the repository in the controller, where you can specify the SQL command as I have shown. Start here https://loopback.io/doc/en/lb4/Getting-started.html.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/strongloop/loopback-next/issues/4869#issuecomment-705467801, or unsubscribe https://github.com/notifications/unsubscribe-auth/AQYR57UMXEA5HBUAUIJX26TSJWFA5ANCNFSM4LGLMYWQ .