code: function findOneOrCreatePlugin(schema) {
      schema.statics.findOneOrCreate = function findOneOrCreate(condition, doc, callback) {
          var self = this;
  
          self.findOne(condition, function(err, result ) {
              if (result) {
                  callback(err, result);
              } else {
                  self.create(doc, function(err, result) {
                      callback(err, result);
                  });
              }
          });
      };
  }
docs: Mongoose Plugin: findOneOrCreate
  Copyright(c) 2014 Mohammad Khan <mohammad.khan@gmx.us>
  MIT Licensed