JayData.org

Use JayData as oData producer and consumer on windows with Node.js

Author: Gábor Dolla November 21st, 2012


Starting from JayData version 1.2.4 you can use JayData on windows as producer (server) and consumer (client) with nodejs.

In this blogpost we already documented how to use JayData as an oData server with mongoDB, the procedure on windows is the same:

– install mongoDB

– install nodejs and npm

– npm install jaydata express xmldom

– create your context and server code

– start your server

If you want to run nodejs as a windows service then use can use tools like Winser.

To use JayData to consume an oData datasource you must use static context definition. JayData can build its data model in two ways:

– static context definition: either you define the context manually or have JaySvcUtil to generate it for you or if you use JayStorm then JayStorm can also generate it for you

– dynamic context definition: you tell JayData where your $metadata can be found and JayData does the rest

Dynamic context requires xml manipulation and unfortunately libxmljs does not work on windows yet so on windows we can not support dynamic context now but we will once libxmljs will be available.

So how do you use JayData as an oData client with nodejs ? Here’s a little example:

In this example, I used JayStorm Open as the server, which is a free hosted solution based on JayData. The cool thing is that I did not have to write this code, I just defined my data model and JayStorm generated this code for me along with code for other environments and languages (HTML5, C#, Ruby, Java, PHP) so it’s really cool. Have I mentioned that you can try it for free ? Do try it now.

Of course, you can use JayData as a client with any other oData datasources.

If you’re an Azure user then you can use JayData with Azure Web Site and you can use JayData with WebMatrix, too. We’ll publish a detailed blogpost on that topic really soon.