"use strict";

var q = require("q");
var logger = require('../../utils/Logger').loggers.get('db');

module.exports.preProcess = function(field, document) {
    var deferred = q.defer();

    if (!document[field.name]) {
        logger.info("Setting static value in field: " + field.value);
        document[field.name] = field.value;
        deferred.resolve(document);
    } else {
        deferred.resolve(document);
    }

    return deferred.promise;
};