Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

link up lift model to parser

  • Loading branch information...
commit 0e21277aa6bfc4df12a933824991d4b3536c09e6 1 parent 8c15a1d
@mikepmunroe authored
Showing with 18 additions and 0 deletions.
  1. +18 −0 parsers/wicked.js
View
18 parsers/wicked.js
@@ -1,7 +1,19 @@
var FeedParser = require('feedparser'),
request = require('request'),
+ mongoose = require('mongoose'),
+ path = require('path'),
+ fs = require('fs'),
result = [];
+// Bootstrap models
+var modelsPath = path.join(__dirname, '../models');
+fs.readdirSync(modelsPath).forEach(function (file) {
+ if (/(.*)\.(js$|coffee$)/.test(file)) {
+ require(modelsPath + '/' + file);
+ }
+});
+
+var Wod = mongoose.model('Wod');
var feed = 'http://www.crossfitwicked.com/feeds/rss_3.xml';
var req = request(feed, {timeout: 10000, pool: false});
@@ -36,7 +48,13 @@ function done(err) {
console.log(err, err.stack);
return process.exit(1);
}
+
console.log(result);
+ save(result);
return done(result);
process.exit();
}
+
+function save(result) {
+ new Wod({ description: result.wod });
+};
Please sign in to comment.
Something went wrong with that request. Please try again.