edx-modulestore
Advanced tools
Comparing version 0.0.10 to 0.0.11
@@ -1,27 +0,11 @@ | ||
var EventEmitter = require('events').EventEmitter; | ||
var proto = require('./modulestore') | ||
var _ = require('lodash'); | ||
var Modulestore = require('./modulestore') | ||
// ## // | ||
/* | ||
** Public functions | ||
*/ | ||
function createModuleStore(options) { | ||
var modulestore = {}; | ||
options = options || {}; | ||
_.merge(modulestore, proto); | ||
_.merge(modulestore, EventEmitter.prototype); | ||
modulestore.initialize(options); | ||
return modulestore; | ||
var setup = function (options) { | ||
return new Modulestore(options); | ||
} | ||
// ## // | ||
/* | ||
** Exports | ||
*/ | ||
module.exports = createModuleStore; | ||
module.exports = setup; |
var Q = require('q'); | ||
var EventEmitter = require('events').EventEmitter; | ||
var mongoose = require('mongoose'); | ||
@@ -8,11 +9,5 @@ var _ = require('lodash'); | ||
// ## // | ||
var modulestore = {}; | ||
/* | ||
** Private methods | ||
*/ | ||
modulestore.initialize = function (options) { | ||
var Modulestore = function (options) { | ||
this.connection = null; | ||
@@ -25,7 +20,6 @@ | ||
/* | ||
** Public methods | ||
*/ | ||
_.merge(Modulestore.prototype, EventEmitter.prototype); | ||
modulestore.connect = function (options) { | ||
Modulestore.prototype.connect = function (options) { | ||
var connection = mongoose.createConnection(options); | ||
@@ -35,3 +29,3 @@ return this.attachConnection(connection); | ||
modulestore.attachConnection = function (connection) { | ||
Modulestore.prototype.attachConnection = function (connection) { | ||
var deferred = Q.defer(); | ||
@@ -66,3 +60,3 @@ | ||
modulestore.detachConnection = function () { | ||
Modulestore.prototype.detachConnection = function () { | ||
if (!this.connection) { | ||
@@ -78,3 +72,3 @@ throw new Error('modulestore: no connection attached'); | ||
modulestore.disconnect = function () { | ||
Modulestore.prototype.disconnect = function () { | ||
this.connection.close(); | ||
@@ -84,3 +78,3 @@ return this; | ||
modulestore.findCourses = function (filter) { | ||
Modulestore.prototype.findCourses = function (filter) { | ||
return Course.find(this, filter); | ||
@@ -90,3 +84,3 @@ }; | ||
modulestore.findCourse = function (id) { | ||
Modulestore.prototype.findCourse = function (id) { | ||
return Course.findById(this, id); | ||
@@ -96,3 +90,3 @@ }; | ||
modulestore.findOrganizations = function (filter) { | ||
Modulestore.prototype.findOrganizations = function (filter) { | ||
return Organization.find(this, filter); | ||
@@ -106,2 +100,2 @@ }; | ||
module.exports = modulestore; | ||
module.exports = Modulestore; |
{ | ||
"name": "edx-modulestore", | ||
"version": "0.0.10", | ||
"version": "0.0.11", | ||
"description": "Easy browsing of Open edX modulestores", | ||
@@ -5,0 +5,0 @@ "author": "Bertrand Marron", |
15857
12
492