Skip to content

Instantly share code, notes, and snippets.

@Pitbi
Created September 17, 2012 19:54
Show Gist options
  • Save Pitbi/3739403 to your computer and use it in GitHub Desktop.
Save Pitbi/3739403 to your computer and use it in GitHub Desktop.
TypeError: Object function () {
if (arguments.length === 1) {
var arg = arguments[0];
if (typeof arg === 'object') {
// object setter
// iterate keys/value to set attributes
for (var k in arg) {
this._attr(k, arg[k]);
};
return this;
} else if (typeof arg === 'string') {
// getter
return this._attr(arg);
}
} else if (arguments.length === 2) {
// 2 arg setter
var name = arguments[0];
var value = arguments[1];
this._attr(name, value);
return this;
}
} has no method 'forEach'
var drivers = xml.find("//Driver");
drivers.forEach(function (driver) {
var driverName = "" + driver.get("Name").text();
var laps = driver.find("Lap");
Driver.findOne({name : driverName}).exec(function (err, driverFound) {
if (driverFound != null) {
laps.forEach(function (lap) {
console.log(lap.attr);
lap.attr.forEach(function (lapAttribute) {
console.log(lapAttribute.value());
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment