var Model = (function() {

  /**
   * Mogwai Model class
   *
   * Models are ultimately stored as at least 1 Vertex in the database. That
   * vertex will be identified by a special "$type" property set to the
   * name of the Model defined in the Schema. See ModelCompiler.compile().
   */
  function Model() {}

  /**
   * Execute a Grex query.
   *
   * @param {Grex} grexQuery
   * @param {Function} callback
   */
  Model.prototype.exec = function(grexQuery, callback) {
    console.log("Grex:", grexQuery.params);

    grexQuery.then(function(success) {
      return callback(null, success);
    }).fail(function(err) {
      console.error(err);
      return callback(err);
    });
  };

  /**
   * Save a Model instance.
   * Will insert if new, or update if already present (currently checks for
   * the existence of a vertex _id).
   *
   * @param {Function} callback
   */
  Model.prototype.save = function(callback) {
    if (this.hasOwnProperty("_id")) {
      // Vertex already exist, just update it
      return this.update(callback);
    } else {
      // Missing, insert a new vertex
      return this.insert(callback);
    }
  };

  /**
   * Update a Model instance properties.
   *
   * @see update() function definition in model.groovy
   * @param {Function} callback
   */
  Model.prototype.update = function(callback) {
    var propertiesMap = {},
        propertyValue;

    // Build property map only for properties defined in the Schema
    for (var propertyName in this.schema.properties) {
      propertyValue = this[propertyName];
      propertiesMap[propertyName] = propertyValue;
    }

    this.scripts.update(this._id, propertiesMap).execute(function(err, results) {
      return callback(err, results);
    });
  };

  /**
   * Insert a new Model with given doc properties
   *
   * @param {Function} callback
   */
  Model.prototype.insert = function(callback) {
    var doc,
        transaction,
        property,
        properties = this.schema.properties;
    var gremlin = this.g.gremlin();

    doc = this;
    // Assign Mogwai reserved "$type" property
    doc.$type = this.$type;

    transaction = gremlin.g;
    v = transaction.addVertex(doc.toObject());

    for (var name in properties) {
      property = properties[name];

      if (property.isIndexed()) {
        v.addProperty(name, this[property.name]);
      } else {
        v.setProperty(name, this[property.name]);
      }
    }

    return this.exec(gremlin.exec(), callback);
  };

  /**
   * Transform a Model instance as a raw JavaScript object
   *
   * @return {Object}
   */
  Model.prototype.toObject = function() {
    var o = {};

    for (var propertyName in this) {
      if (this.hasOwnProperty(propertyName)) {
        o[propertyName] = this[propertyName];
      }
    }

    return o;
  };

  /**
   * Execute a Gremlin query, return results as raw model instances or raw
   * elements.
   *
   * @param {String} gremlinQuery - Gremlin query to execute
   * @param {Boolean} retrieveAsModels - Indicate whether the data should be retrieved
   *      as model instances (true) or as a raw graph elements (false).
   * @param {Function} callback
   */
  Model.find = function(gremlinQuery, retrieveAsModels, callback) {
    // Handle optional 'retrieveAsModels' parameter
    if (typeof retrieveAsModels === "function") {
      callback = retrieveAsModels;
      retrieveAsModels = true;
    }

    if (retrieveAsModels === true) {
      return this.gremlin(gremlinQuery, callback);
    } else {
      return this.gremlin(gremlinQuery).execute(callback);
    }
  };


  return Model;

})();

module.exports = Model;
@@ -312,388 +312,8 @@
 %7B%7D%0A%0A
-  /**%0A   * Execute a Grex query.%0A   *%0A   * @param %7BGrex%7D grexQuery%0A   * @param %7BFunction%7D callback%0A   */%0A  Model.prototype.exec = function(grexQuery, callback) %7B%0A    console.log(%22Grex:%22, grexQuery.params);%0A%0A    grexQuery.then(function(success) %7B%0A      return callback(null, success);%0A    %7D).fail(function(err) %7B%0A      console.error(err);%0A      return callback(err);%0A    %7D);%0A  %7D;%0A%0A
   /*
@@ -342,16 +342,16 @@
 stance.%0A
+
    * Wil
@@ -1234,16 +1234,29 @@
   %7D%0A%0A   
+ var script =
  this.sc
@@ -1292,16 +1292,28 @@
 tiesMap)
+;%0A    script
 .execute
@@ -1551,38 +1551,17 @@
  doc
-,%0A        transaction,%0A       
+;%0A    var
  pro
@@ -1565,25 +1565,25 @@
 property
-,
+;
 %0A    
-   
+var
  propert
@@ -1745,27 +1745,21 @@
 e;%0A%0A    
-transaction
+var g
  = greml
@@ -1773,22 +1773,16 @@
    v
- = transaction
+ar v = g
 .add
@@ -2056,18 +2056,8 @@
 urn 
-this.exec(
 grem
@@ -2069,11 +2069,8 @@
 xec(
-), 
 call

Remove Model.exec(). More switch to gRex new API.