/** * Create bid object for the bid manager */ function createBidObject(resp, bid, width, height) { return utils.extend(bidfactory.createBid(1, bid), { bidderCode: bid.bidder, ad: formatAdMarkup(resp), width: width, height: height, cpm: parseFloat(resp.price) }); }
insert: function(options, callback) { options = utils.extend({ docs: [], collection: '' }, options || {}); this._collection(options.collection, function(collection){ if (collection) { collection.insert(options.docs, {safe: true}, function(error, documents) { documents = documents || []; if (error) { console.error(error); } callback.call(null, error, documents); }); } else { callback.call(null, 'unknown collection', []); } }); },
update: function(options, callback) { options = utils.extend({ critera: {}, doc: {}, options: {} }, options || {}); this._collection(options.collection, function(collection) { if (collection) { collection.update(options.criteria, options.doc, options.options, function(err, results) { if (err) console.error(err); callback.call(null, err, results); }); } else { callback.call(null, 'unknown collection', []); } }); },
remove: function(options, callback) { options = utils.extend({ criteria: {}, collection: '' }, options || {}); this._collection(options.collection, function(collection) { if (collection) { console.error(options.criteria); collection.remove(options.criteria, function(error, result) { result = result || []; if (error) { console.error(error); } callback.call(null, error, result); }); } else { callback.call(null, 'unknown collection', []); } }); },
find: function(options, callback) { options = utils.extend({ query: {}, options: {}, fields: {}, collection: '' }, options || {}); this._collection(options.collection, function(collection){ if (collection) { var query = collection.find(options.query, options.fields, options.options); query.toArray(function(error, documents){ documents = documents || []; if (error) { console.error(error); } callback.call(null, error, documents); }); } else { callback.call(null, 'unknown collection', []); } }); },
/** * Create empty bid object for the bid manager */ function createEmptyBidObject(bid) { return utils.extend(bidfactory.createBid(2, bid), { bidderCode: bid.bidder }); }