How to run server-side code programmatically in MongoDB - mongodb

I need to define some js codes and run them in the server side. I know how to run them thru the mongo shell but I need to do this programmatically. How can I do this?

You can use grails drivers like mongodb/gmongo. For example I use the MapReduceCommand
to execute map/reduce command with Javascript syntax.
Enjoy

After some Internet search, I ran into a PHP solution from http://pointbeing.net/weblog/2010/08/getting-started-with-stored-procedures-in-mongodb.html

Related

Using Saxon/C with Perl

The Saxon website says Saxon/C can be invoked from Perl, but I can't find any examples. The only thing I've found that interfaces to Saxon is one old Perl module (XML::Saxon::XSLT2) which uses Inline::Java and apparently is very slow. But I can find nothing that uses Saxon/C. Has anyone had any success in doing this who can share some tips?
we have not yet officially done the integration work needed to extend Saxon/C on perl it is still on our todo list. Therefore we currently don't support it. I don't know of anyone who has done this work as yet but I know it is can be done.
On the Saxon website we state that it is possible to create extensions in languages like Perl since Saxon/C has a C/C++ interface. Currently, we only have extensions for PHP and Python (available in the next release).
As a workaround you could run the transform command from Saxon/C using the exec function in Perl instead of the Java version, therefore avoiding the need to run Java VM.

how to execute SOAP UI test cases with command line

Currently in our project we have automated SOAP UI test cases. Our requirement is to run these automated scripts from command line. So is there anyway to generate a batch program to execute these instead of running from the soap GUI?
Thanks,
Kumar
Yes, it is very much possible.
SoapUI provides utilities under SOAPUI_HOME/bin directory.
testrunner.bat( or.sh) utility helps to execute the project command line. This has various options as well.
For more details, refer documentation.

How do I build an installer for my perl application with DB?

I've been searching for a while and I cannot find an easy solution for building an install package on linux for a perl application I've built. My application is a mojolicious application and I am using DBIx::Schema. I need to accomplish the following;
import my DB schema into a database
check for and install any missing perl modules
copy my actual application to a location.
possibly set my application to run as a service.
This is rather trival on windows, but I can't seem to find a clean solution to do this on Linux. Is the easiest approach to just write another perlscript to do the install?
thanks.
Try to use Rex or checkout this SO question Is there a Perl or Lua alternative to Capistrano?.
To deploy your DBIx::Class::Schema you can use $schema->deploy in an install script. It uses SQL::Translator to generate the SQL statements for your RDBMS of choice.
Another possibility to generate the SQL statements in the app build process and store them in text files per supported RDBMS using $schema->deployment_statements.
Many people package their apps like CPAN modules so they can't be installed using the CPAN toolkit apps like cpan, cpanminus or cpanplus.

How to run coffeescript via StrongLoop controller

I'm making LoopBack application and I wonder how I can use coffeescript on serverside, so I could use slc run?
I've used LoopBack recently, and wrote the backend code in coffeescript. The catch is that you can't use the slc run command to run it. Instead, after generating the initial application skeleton with slc, rewrite your main server file in coffeescript. The quickest way to do that is probably to convert it with js2coffee:
npm install -g js2coffee
js2coffee server/server.js > server/server.coffee
rm server/server.js
Then kickoff your LoopBack server using coffee instead of slc run
npm install -g coffee-script
coffee server/server.coffee
This starts the server just like any other node.js app, and you get to write any of your server files in coffeescript, without needing to precompile them first with grunt, etc.
If you feel like you're missing out on some of the bonus features of slc run like clustering and process monitoring, you could try pm2 as a generalized alternative. It supports coffeescript out of the box. Hopefully in the future (hint hint, StrongLoop), the slc tool will, too.
looking at the getting started guide for strongloop it looks like it depends on yeoman and grunt, so, I'd just use grunt to compile your cs to js when the build process runs. grunt-contrib-coffee would be a good place to start.
http://docs.strongloop.com/display/SLC/Getting+started+with+StrongLoop+Controller
https://github.com/gruntjs/grunt-contrib-coffee

How to require scripts in Mongo Shell CLI

I'd like to be able to import a library of common tools that I use to make working with MongoDB easier. However, I haven't discovered an easy to to import external scripts into the Mongo CLI. Ideally, this would work similar to Node.js require.
How can I get require working in Mongo CLI by default?
Or, is there some other way to solve external library dependencies?
There are several options for loading JavaScript into the mongo shell:
1) Save the JavaScript to .mongorc.js in your home directory.
2) Save the JavaScript to the global mongorc.js file (MongoDB 2.6+) which is evaluated before the .mongorc.js file in your home directory.
3) Use load('filename.js') from within the shell (or within one of the mongorc.js files).
4) Store your JavaScript on the server using the system.js collection and db.loadServerScripts().
For common JavaScript functions, the first option is the most typical approach.