express-simplemongodbview

0.9.1 • Public • Published

Express-SimpleMongoDBView

Simple Collection Viewer for MongoDB. Designed for users without knowledge about internals. There is no admin access to the MongoDB instance needed. Can also export an collection as CSV file. Use SMOG or Mongo-Express if you need a (full featured) MongoDB client.

Features

View

not implented yet

Export

Exports an collection as CSV file

Installation

$ npm install express-simplemongodbview

SimpleMongoDBView needs serveral modules, see dependencies

Setup

The app needs to know which models to use. So you need an js file with the model definitions. This file has to export the models like this example (databasemodels.js):

var db = require('mongoose'), Schema = db.Schema;

var _MySchema = new Schema({
  id                : Schema.ObjectId,
  type              : { type: Number, required: true }, 
  name              : { type: String, required: false, trim: true, index: { sparse: true } },  
  timestamp         : { type: Date, default: Date.now, required: true }
});
var MySchema = db.model('myschema', _MySchema);
exports.MySchema = MySchema;

SimpleMongoDBView detect all schemas exported the way above.

Now, use it as standalone app:

  var mongoose = require('mongoose');
  var dbview = require('express-simplemongodbview');
  var config = {  
    modelDefinitionFile : __dirname + '/databasemodels.js',
    web: {
      host : 'localhost',
      port : 80
    }
  }
  mongoose.connect('mongodb://localhost:27017/mycollection', {}, function(){
    dbview.start(config);    
  });

Check http://localhost and http://localhost/export

Available options as object:

  • modelDefinitions: an existing object (require)
  • modelDefinitionFile: a file with the model definitons (use only modelDefinitionFile OR modelDefinitions)
  • web.host: The hostname, e.g. localhost
  • web.port: The port, e.g. 8080
  • web.cdnurl: The page uses some external js libs like jQuery, Backbone.js and Underscore.js. You can define an url to an external cdn to deliver these libs from there. Otherwise these libs are served from Express.
  • auth.enabled: can be set to true and a basic authentification (Basic HTTP Auth) jumps in
  • auth.user: the user name for authenticifation (default is admin)
  • auth.password: the user password (default is admin)

You can also use this in your existing applications, change the port accordingly.

Dependencies

License

MIT License

Author

Copyright (c) 2013, [Hendrik Konitzer] (hkonitzer@gmail.com)

Readme

Keywords

none

Package Sidebar

Install

npm i express-simplemongodbview

Weekly Downloads

10

Version

0.9.1

License

MIT

Last publish

Collaborators

  • hkonitzer