Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mongoose-manager

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mongoose-manager - npm Package Compare versions

Comparing version 0.1.1 to 0.1.2

6

lib/admin.js

@@ -42,3 +42,3 @@ var express = require('express'),

}
return this.getFields(modelName, 4);
return this.getFields(modelName, this.options.numberOfFieldsInListView);
};

@@ -73,2 +73,6 @@

app.use(express.session());
app.use(function(req, res, next){
res.locals.errors = {};
next();
});
app.use(require('../views/helpers').init(this));

@@ -75,0 +79,0 @@ app.use(app.router);

3

lib/defaults.js
exports.defaults = {
pageSize: 100
pageSize: 100,
numberOfFieldsInListView: 5
};

@@ -10,15 +10,23 @@ var async = require('async'),

function loadDocuments(req, res, next){
var pageSize = admin.options.pageSize,
model = admin.getModel(req.params.model),
page = parseInt(req.query.page, 10) || 1,
skip = (page - 1) * pageSize,
q = req.query.q,
fields = admin.getListFields(req.params.model);
var pageSize = res.locals.pageSize = admin.options.pageSize,
model = res.locals.model = admin.getModel(req.params.model),
page = res.locals.page = parseInt(req.query.page, 10) || 1,
skip = res.locals.skip = (page - 1) * pageSize,
q = res.locals.q = req.query.q,
where = res.locals.where = req.query.where,
fields = res.locals.fields = admin.getListFields(req.params.model);
try {
var parsed = JSON.parse(where || '{}');
} catch(e) {
res.locals.errors.where = 'Could not parse where clause. It must be valid JSON.';
return res.render('list');
}
async.parallel([
function(cb){
model.count(cb);
model.count(parsed, cb);
},
function(cb){
model.find().limit(pageSize).skip(skip).exec(function(err, documents){
model.find(parsed).limit(pageSize).skip(skip).exec(function(err, documents){
if (err) return cb(err);

@@ -40,10 +48,4 @@

res.render('list', {
model: model,
documents : results[1],
fields : fields,
count : results[0],
page : page,
pageSize : pageSize,
skip : skip,
q: q,
actions: admin.getActions(req.params.model)

@@ -50,0 +52,0 @@ });

{
"name": "mongoose-manager",
"version": "0.1.1",
"version": "0.1.2",
"scripts": {

@@ -5,0 +5,0 @@ "example": "supervisor --force-watch -i public,views example/app.js"

@@ -11,14 +11,25 @@ $(function(){

}
$("select.autocomplete").select2();
$(document).on('click', '[href^="#remove-item"]', function(){
var $ol = $(this).parents('ol');
$(this).parents('li').remove();
updateCount($ol);
return false;
});
$(document).on('click', '[href^="#add-item"]', function(){
var $ol = $(this).siblings('ol'),
templateId = $ol.data('template'),
templateSelector = $ol.data('template'),
i = $ol.find('.form-group').length,
html = $('#' + templateId).text().replace('{{i}}', i);
html = $(templateSelector).text().replace('{{i}}', i);
$ol.append(html);
updateCount($ol);
return false;
});
function updateCount($list){
$list.parents('.array-field').siblings('label').find('.count').text($list.find('li').length);
}
});

@@ -68,2 +68,6 @@ var moment = require('moment'),

res.locals.noColon = function(word, replacement){
return word.replace(/\./g, replacement || '_');
};
res.locals = _.extend(res.locals, helpers);

@@ -70,0 +74,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc