@function elasticSearchBodyFromRaw

use raw data to build body - used for record creation

@param {ImmutableCoreModel} model
@param {object} raw

@returns {object}
433762
function elasticSearchBodyFromRaw (model, raw) {
    // document to store in elastic search
    var body = {}
    // lookup data in raw and store by default column name
    _.each(model.defaultColumns, (defaultName, name) => {
        // skip c column because elasticsearch is never compressed
        if (name === 'c') {
            return
        }
        body[defaultName] = raw[name]
    })

    return body
}
1368809
function(req, returnReference) {
		getRawBody(req).then(function(bodyBuffer) {
			returnReference.requestBody = bodyBuffer.toString()
		}).catch(function() {
			log('Unhandled error in getRawBody', arguments)
		})
	}
892584
function Document(db, raw) 
{
  var self = this, raw;
  if (raw===undefined) raw = { };
  if (typeof(raw)==="string") raw = deserialize(raw);
  
  Object.defineProperty(this, "save", { value: function(cb) {
    return db.save(self, cb);
  }, writable: false  });

  Object.defineProperty(this, "remove", { value: function(cb) {
    if (! self._id) return cb(); // TODO maybe emit error
    return db.remove({ _id: self._id }, { }, cb);
  }, writable: false  });

  Object.defineProperty(this, "update", { value: function(modifier, cb) {
    if (self._id === undefined) self._id = db.createNewId();
    return db.update({ _id: self._id }, modifier, { upsert: true }, cb);
  }, writable: false  });

  Object.defineProperty(this, "copy", { value: function(strict) { 
    return deepCopy(self, strict);
  }, writable: false });

  Object.defineProperty(this, "serialize", { value: function(strict) {
    return serialize(self);
  }, writable: false });

  // Special methods
  for (var method in db._methods) Object.defineProperty(this, method, { value: db._methods[method], writable: false });

  // Persist to LevelUP
  Object.defineProperty(this, "_persist", { value: function(cb, quiet) {
    if (!quiet) db.emit("save", self);
    db.store.put(self._id, self.serialize(), function(err) {
      cb(err || null, err ? undefined : self);  
    });
  } });

  _.extend(this, raw.constructor.modelName ? deepCopy(raw) : raw); // Clone it deeply if it's schema-constructed
  schemas.construct(this, db.schema);
  db.emit("construct", self);
}
650584
function getByIdQuery(modelInstance) {
    const modelClass = modelInstance.getClass();
    const { idAttribute, modelName } = modelClass;

    return {
        table: modelName,
        clauses: [
            {
                type: FILTER,
                payload: {
                    [idAttribute]: modelInstance.getId(),
                },
            },
        ],
    };
}
751769
def raw
      raise ModelNotAvailableAsRawError, model unless model.exposable_as_raw?

      self.class.new(model: model, api: api, constraints: constraints.merge(accept: model.raw_mime_type))
    end
212418
function search (args) {
    // currently only raw mode is supported
    assert.ok(args.raw, 'elasticsearch only supports raw mode')
    // get raw mode property if set
    if (args.raw) {
        var raw = true
        // remove from args for elasticsearch
        delete args.raw
    }
    // get session if set
    if (args.session) {
        // not currently used
        delete args.session
    }
    // get elastic search client - throws error if no client
    var elasticsearchClient = this.elasticsearch()
    // do search
    return elasticsearchClient.search(args)
}
570484
function insert(model) {
      model = this.records.add(model, { merge: true });
      return Promise.resolve(model);
    }
1112500
function(req, res) {
    let id = req.allParams()['id'];
    let model = pluralize.singular(req.param('model'));

    req.options.controller = model;
    req.options.model = model;

    if (sails.controllers[model].update !== undefined) {
      return sails.controllers[model].update(req, res);
    } else {
      req.body = JsonApiService.deserialize(req.body);
      return JsonApiService.updateOneRecord(req, res);
    }
  }
956968
public org.w3c.dom.Node getMessageBody(Object rawData, boolean bReturnCopy)
    {
        if (this.getRawData() instanceof String)
        {   // Always
            String strXML = this.getXML();
            return Utility.convertXMLToDOM(strXML);
        }
        return super.getMessageBody(rawData, bReturnCopy);
    }
878097
def load_raw(cls, model_fn, schema, *args, **kwargs):
        
        c = cls(*args, **kwargs)
        c.schema = schema.copy(schema_only=True)
        c._model_data = open(model_fn, 'rb').read()
        return c
677427
def cache_data_model(self, raw):
        
        output_json = json.loads(raw.content)
        output_file = self.find_cached_dm()
        json.dump(output_json, open(output_file, 'w+'))
947206
function (model) {

                var ret = [];

                function getSubModel(obj) {

                    if (obj === model) {
                        return;
                    }

                    if (_.indexOf(ret, obj) !== -1) {
                        // already in list
                        return;
                    }

                    if (obj instanceof Model) {
                        ret.push(obj);
                        return;
                    }

                    for (var key in obj) {
                        if (obj.hasOwnProperty(key)) {
                            var value = obj[key];

                            if (value instanceof Array) {
                                for (var i = 0; i < value.length; i++) {
                                    getSubModel(value[i]);
                                }
                            } else if (value instanceof List) {
                                value.each(getSubModel);
                            } else if (value instanceof Object) {
                                getSubModel(value);
                            }
                        }
                    }
                }

                getSubModel(model.$);

                return ret;

            }
1065480
function createElasticsearch (args, model) {
    // get client - throw error if not set
    var elasticsearchClient = model.elasticsearch()
    // document to store in elastic search
    var body
    // use raw data to build body
    if (args.raw) {
        body = elasticSearchBodyFromRaw(model, args.raw)
    }
    // use record to build body
    else if (args.record) {
        body = elasticSearchBodyFromRecord(model, args.record)
    }
    else {
        // ignore errors
        return
    }
    // get id from originalId or id
    var id = body.originalId || body.id
    // if instance does not have id cannot store
    if (!id) {
        // ignore errors
        return
    }
    // get record type
    var type = model.esType
        ? _.get(body.data, model.esType) || model.name
        : model.name
    // if record is deleted then delete from elasticsearch
    if (body.isDeleted) {
        return elasticsearchClient.delete({
            id: id,
            index: model.esIndex,
            type: type,
        })
        // ignore error
        .catch(console.error)
    }
    // otherwise create/update record with elasticsearch
    else {
        return elasticsearchClient.index({
            body: body,
            id: id,
            index: model.esIndex,
            type: type,
        })
        // ignore error
        .catch(console.error)
    }
}
11111
function _create(model, payload, Log) {
  let request = { payload: payload }
  return _createHandler(model, request, Log)
}
112100
function Model(model) {
    this.child = window;
    this.model = model;
    this.parent = this.child.parent;
    return this.sendHandshakeReply();
  }
462348
function applyModelViewRecordAsynchronous (raw) {
    // get data column
    var dataColumn = this.query.model.columnName('data')
    // apply model views to data
    return Promise.all(_.map(this.modelViews.record.asynchronous, modelView => {
        // if this model view applies to meta data then pass entire db record
        var data = modelView.meta ? raw : raw[dataColumn]
        // call each function with modelView and data
        return modelView.each({
            modelView: modelView,
            record: data,
            session: this.query.session,
        })
        // merge result to data
        .then((eachData => {
            _.merge(data, eachData)
        }))
    }))
    // resolve with merged data
    .then(() => raw)
}
879727
function model(spec) {
  var schema = lodash.cloneDeep(spec);

  delete schema.id;

  schema = transform(schema, {
    removeFormats: true,
  });

  return schema;
}