Using Breeze.js EntityManager from Node

I am interested in being able to use the capabilities of the Breeze.js EntityManager and the queries in the console console service node to access a remote data service that provides a RESTful endpoint compatible with BreezeJS / OData.

We currently have a Data Service implemented using Node.js, MongoDB and the Breeze.js breeze-mongodb module.

We have client web browsers that access MondgoDB using the Breeze.js client API (EntityManager) and the data service described above.

I need to create another Node.js service that can access the same MongoDB database as clients hosted in a web browser, and for consistency / simplicity I would like to use the same data acceess API as in the web Browser.

Has anyone experimented with this configuration?

I experimented with loading Breeze and its dependencies using the Node.js module infrastructure, but I get errors when Breeze tries to initialize Angular as an ajax handler. Angular is installed and configured as a dependency on the node module, but I get an error:

Error: [$ injector: nomod] http://errors.angularjs.org/1.2.2/ $ injector / nomod? p0 = ngLocale

In theory, I don't need angular, but I get additional errors if Angular is not.

I can debug this specific problem, but it will require a detailed change to the Breeze.js code and possibly its change to fix it. It was curious if anyone else got this job.

+4
2

Node. , - , , ... : -)

: , -, , breezejs DB.

, , , - ajax, DB- - - , API.

    var ctor = function () {
        this.name = 'node';
        this.defaultSettings = { };
    };

    ctor.prototype.initialize = function () {
    };
    var query = require('../../../../server/db/query');

    ctor.prototype.ajax = function (config) {
        if (config.url === '/api/all') {
            query.get()
                .then(function (result) {
                    var httpResponse = {
                        data: result,
                        status: '400',
                        getHeaders: undefined,
                        config: config
                    };
                    config.success(httpResponse);
                })
                .otherwise(function (error) {
                    var httpResponse = {
                        data: '',
                        status: '500',
                        getHeaders: undefined,
                        error: error,
                        config: config
                    };
                    config.error(httpResponse);
                });
        } else if (config.url === '/api/SaveChanges') {
            query.save(JSON.parse(config.data))
                .then(function (result) {
                    var httpResponse = {
                        data: result,
                        status: '400',
                        getHeaders: undefined,
                        config: config
                    };
                    config.success(httpResponse);
                })
                .otherwise(function (error) {
                    var httpResponse = {
                        data: '',
                        status: '500',
                        getHeaders: undefined,
                        error: error,
                        config: config
                    };
                    config.error(httpResponse);
                });
        }


    };

    breezejs.config.registerAdapter('ajax', ctor);
    breezejs.config.initializeAdapterInstance('ajax', 'node', true);
+2

. Breeze Node, . Breeze User Voice. .

0

All Articles