Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gabrielbb/rss-node-mongo
RNM is a Node JS module to request and parse a RSS feed and save the contents to Mongo DB
https://github.com/gabrielbb/rss-node-mongo
Last synced: 16 days ago
JSON representation
RNM is a Node JS module to request and parse a RSS feed and save the contents to Mongo DB
- Host: GitHub
- URL: https://github.com/gabrielbb/rss-node-mongo
- Owner: GabrielBB
- Created: 2017-08-06T17:32:30.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-04-01T15:27:37.000Z (over 6 years ago)
- Last Synced: 2024-10-04T16:50:09.618Z (about 1 month ago)
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/rss-node-mongo
- Size: 15.6 KB
- Stars: 11
- Watchers: 1
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# rss-node-mongo
![see module on NPM](https://nodei.co/npm/rss-node-mongo.png?downloads=true&downloadRank=true&stars=true)
RNM is a Node JS module to request and parse RSS feeds and save the contents to Mongo DB. It makes sure only the new content is appended to your collection. You only provide the RSS URI and your database connection string and it is done.
Important Note: This module is only for version 8 of Node JS. We are working on a new version with backward compatibility
## Usage```javascript
const RSSToMongo = require('rss-node-mongo');const rss = new RSSToMongo(properties)
rss.work(function (err, success) {
if (!err) {
console.log(success.saved + " items were inserted")
} else {
console.error(err)
}
})
```**properties**
This parameter can have the following properties:
- `rss`: The RSS URL
- `db`: The mongo db connection string (if not provided it creates a database named "rss" under mongodb://localhost:27017)
- `collection`: Name for the collection where items will be saved (if not provided then it creates a collection named "feeds")**success**
This object has the following properties:
- `saved`: Number of items that were inserted to database
- `total`: Total number of items from the RSS
- `ignored`: Number of items that were ignored because they were already in the database collection## Further
You can also pass a function as a second parameter of the class that will be called for each retrieved item.
```javascript
const rss = new RSSToMongo(properties, function(item) {
// The item will be inserted with the changes you make here to the database.item._id = item.link; // For example, you might want your _id to be something else
item["PutNewPropertyNameHere"] = "I'm additional": // Or Add an additional property
// Or remove special characters from the item content
})
```### Installation
Install the dependency
``` sh
npm install rss-node-mongo
```