Does Loopback support mssql stored procedures yet?

1,570 views
Skip to first unread message

Nathan Stowell

unread,
Jul 22, 2015, 3:05:25 PM7/22/15
to LoopbackJS
Hello everyone,

I am in the process of putting together a plan for my company to build a restful api for our applications and having used Strongloop on my own personal projects I wanted to push for its use here as well.  The only major problem is that so much of our company's biz logic is housed inside of stored procedures.  I am planning on bypassing most of them in favor of Strongloop's models, but they are insisting that we make use of the stored procedures for certain tasks.  My question is if Loopback's connectors are able to call stored procedures yet?  I haven't been able to find any documentation on this either way, but wanted to make sure that I wasn't missing something somewhere.  Thanks in advance for any help you can provide


Raymond Feng

unread,
Jul 22, 2015, 3:22:57 PM7/22/15
to loopb...@googlegroups.com
Short term: Use native SQL execution. For example,
var sql = 'USE AdventureWorks2012;\r\nEXEC dbo.uspGetEmployeeManagers 6;\r\n'
ds.connector.execute(sql, [], console.log);
Long term: Extend the model definition to map a method to a stored procedure. This way, calling a stored procedure is just invoking a Node.js method on the model class. We can also potentially create the stored procedure as part of ‘automigrate’ . This requires some work. 

Thanks,

---
Raymond Feng
Co-Founder and Architect @ StrongLoop, Inc.

StrongLoop makes it easy to develop APIs in Node, plus get DevOps capabilities like monitoring, debugging and clustering.

On Jul 22, 2015, at 12:05 PM, Nathan Stowell <n8st...@gmail.com> wrote:

Hello everyone,

I am in the process of putting together a plan for my company to build a restful api for our applications and having used Strongloop on my own personal projects I wanted to push for its use here as well.  The only major problem is that so much of our company's biz logic is housed inside of stored procedures.  I am planning on bypassing most of them in favor of Strongloop's models, but they are insisting that we make use of the stored procedures for certain tasks.  My question is if Loopback's connectors are able to call stored procedures yet?  I haven't been able to find any documentation on this either way, but wanted to make sure that I wasn't missing something somewhere.  Thanks in advance for any help you can provide



--
You received this message because you are subscribed to the Google Groups "LoopbackJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to loopbackjs+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/loopbackjs/ca161438-9496-4f88-8dd3-c169722d1d06%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Nathan Stowell

unread,
Jul 23, 2015, 12:37:33 PM7/23/15
to LoopbackJS, ray...@strongloop.com
Awesome, thank you!

I think built in support would be awesome, but not sure if enough people would really want/need that functionality to justify the effort required to implement it.

Nathan Stowell

unread,
Aug 12, 2015, 4:51:59 PM8/12/15
to LoopbackJS
So this is technically working.  I can receive data returned by the stored procedure.  However my company is using stored procedures that return multiple record sets.  Right now loopback is only giving me the first record set back.  Is there a way to get all of the record sets returned?

Thanks in advance

Deepak Jha

unread,
Nov 21, 2017, 3:50:09 AM11/21/17
to loopb...@googlegroups.com
i am using loopback v.4 and getting error connector is not available in datasource ,i don`t know is connector a method that is defined in datasource or the 
//its my get api
@get('/user')
async findUser(): Promise<User[]> {
var sql = 'FastDryNew;\r\nEXEC SP_GetCustomerById;\r\n' return db.connector.execute(sql, [], console.log);

}


//its my db connection
import { DataSourceConstructor} from '@loopback/repository';

export const db = new DataSourceConstructor({
connector: 'mssql',
host: '192.168.1.110',
port: 1433,
database: 'FastDryNew',
password: 'sa$123',
user: 'sa',
});

Jacob Drew

unread,
Jan 10, 2018, 4:55:15 PM1/10/18
to LoopbackJS
I know this is a few years old, but it still pops up when you google "mssql stored procedures loopback". I'm in a similar situation-- would like to use loopback with a some legacy sprocs, but wary since it's not common. Did it work out for you? Were you able to capture multiple recordsets from sprocs that returned them?

Thanks!

Michael DeMutis

unread,
Apr 18, 2018, 11:21:50 AM4/18/18
to LoopbackJS
I hate to post a #metoo but has there been any movement on this?  I use MSSQL and everything we do is based on stored procedures.    

Prasad

unread,
Aug 13, 2018, 8:39:59 AM8/13/18
to LoopbackJS
Hello Raymond,

I have been trying to use MySQL stored procedures along with LoopBack 3.x Rest API. I haven't got any luck since a month. 

It will be deeply appreciated if you can provide a step by step sample code for the same or any blog / post which can provide help. Any help which can solve this issue. I having been trying this since a month. Thanks.
Reply all
Reply to author
Forward
0 new messages