Skip to content

JSMumps.setObject()

John Willis edited this page Mar 21, 2017 · 2 revisions

Stores an ECMAScript object in a MUMPS global.

    jsm.setObject(global, subscripts, object, callback);

Arguments

  • global

The name of the MUMPS global into which the object will be stored.

  • subscripts

An ECMAScript array indicating the subscript level within global into which the object will be stored

  • object

The ECMAScript object to be stored into global

  • callback

The callback to be called when the object has been stored.

Example

This example will store object bobAccount into ^ACCOUNT("bob").

    const jsmumps = require('jsmumps');
    var jsm = new jsmumps.JSMumps();

    var bobAccount = {
        email: '[email protected]',
        birthday: '10/22/1958'
        name: {
            first: 'Bob',
            last: 'Dobbs'
        }
    };

    jsm.setObject('ACCOUNT', ['bob'], bobAccount, (err, data) => {
        if(!err) {
            console.log('Account stored successfully!');
        }
    });

After running the above example, the database will appear as follows:

    ^ACCOUNT("bob","email")="[email protected]"
    ^ACCOUNT("bob","birthday")="10/22/1958"
    ^ACCOUNT("bob","name","first")="Bob"
    ^ACCOUNT("bob","name","last")="Dobbs"
Clone this wiki locally