activity-streams-mongoose

Activity Streams Engine using MongoDB(Mongoose odm) and Redis

npm install activity-streams-mongoose
38 downloads in the last month

Overview

Activity Streams is a simple specification used to describe social actions around the web. http://activitystrea.ms

This library provides the following Activity Stream Models on Mongoose:

  • ActivityObject
  • Activity

For details on the properties each see pne of the following specifications:

Usage

First require the library passing an instance of Mongoose

var mongoose = require('mongoose');
mongoose.connect(siteConf.mongoUrl);
var asmsDB = require('activity-streams-mongoose')(mongoose);

To create an activity object you can do

var cf = new asmsDB.ActivityObject({displayName: "Cloud Foundry" , url: "http://www.cloudfoundry.com"});
cf.save(function (err) {
    //...
    }
});

To create an activity with an associated activity object you can do


var testAct = new asmsDB.Activity({title: "Started the app", target: target._id});
testAct.save(function (err) {
    //...
});

To query the Activity Streams do

Asking for the latest 5:

asmsDB.getActivityStream(5, function (err, docs) {
   docs.forEach(function(doc){console.log(doc);});
});
npm loves you