Comments (8)
Body-parser changes 'ids' to 'ids[]' and if there is only one element the type of 'ids[]' is string.
I wrote a quick workaround for this problem (in formage/lib/controllers.ts):
var modelName = req.params.modelName,
actionId = req.params['actionId'],
ids = ('ids' in req.body) ? req.body.ids : req.body['ids[]'],
model = registry.models[modelName];
ids = (typeof(ids) === 'string') ? [ ids ] : ids;
from formage.
I am getting the exact same error when trying to delete models.
from formage.
👍
Cannot read property 'map' of undefined
TypeError: Cannot read property 'map' of undefined
at _map (f:\www\eliluski\node_modules\formage\node_modules\async\lib\async.js:54:16)
at _asyncMap (f:\www\eliluski\node_modules\formage\node_modules\async\lib\async.js:237:15)
at Object.doParallel [as map] (f:\www\eliluski\node_modules\formage\node_modules\async\lib\async.js:219:23)
at Object.modelConfig.actions.push.func (f:\www\eliluski\node_modules\formage\lib\registry.js:220:19)
at actionDocuments (f:\www\eliluski\node_modules\formage\lib\controllers.js:219:40)
at Layer.handle [as handle_request] (f:\www\eliluski\node_modules\formage\node_modules\express\lib\router\layer.js:76:5)
at next (f:\www\eliluski\node_modules\formage\node_modules\express\lib\router\route.js:100:13)
at afterParseSession (f:\www\eliluski\node_modules\formage\lib\controllers.js:531:32)
at newTickHandler (f:\www\eliluski\node_modules\formage\node_modules\mpromise\lib\promise.js:234:18)
at process._tickCallback (node.js:355:11)
model:
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
var Types = Schema.Types;
var schema = new Schema({
email: { type: String, unique: true },
password: { type: String }
});
schema.methods.toString = function(){
return this.email;
};
module.exports = schema;
express app:
var express = require('express');
var path = require('path');
var favicon = require('serve-favicon');
var logger = require('morgan');
var cookieSession = require('cookie-session');
var bodyParser = require('body-parser');
var models = require('./models');
var mongoose = require('mongoose');
var formage = require('formage');
var routes = require('./routes/index');
var app = express();
app.set('site', 'My Site');
app.set('secret', 'secret');
app.set('mongo', process.env.MONGOLAB_URI);
// view engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'hjs');
// uncomment after placing your favicon in /public
// app.use(favicon(__dirname + '/public/favicon.ico'));
app.use(logger('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: false}));
app.use(cookieSession({secret: app.get('secret'), expires: 604800000}));
app.use(express.static(path.join(__dirname, 'public')));
app.use('/', routes);
formage.init(app, models, {
title: app.get('site') + ' Admin',
username: process.env.ADMIN_PASSWORD || 'admin',
password: process.env.ADMIN_USER || 'admin',
default_section: 'Configurations',
root: '/admin'
});
// catch 404 and forward to error handler
app.use(function (req, res, next) {
var err = new Error('Not Found');
err.status = 404;
next(err);
});
// error handlers
// development error handler
// will print stacktrace
if (app.get('env') === 'development') {
app.use(function (err, req, res, next) {
res.status(err.status || 500);
res.render('error', {
message: err.message,
error: err
});
});
}
// production error handler
// no stacktraces leaked to user
app.use(function (err, req, res, next) {
res.status(err.status || 500);
res.render('error', {
message: err.message,
error: {}
});
});
mongoose.connect(app.get('mongo'));
module.exports = app;
@refack welcome back 😄
from formage.
So much Balagan
On Tue, Jun 23, 2015 at 5:02 PM Alon Valadji [email protected]
wrote:
[image: 👍]
Cannot read property 'map' of undefined
TypeError: Cannot read property 'map' of undefined
at _map (f:\www\eliluski\node_modules\formage\node_modules\async\lib\async.js:54:16)
at _asyncMap (f:\www\eliluski\node_modules\formage\node_modules\async\lib\async.js:237:15)
at Object.doParallel as map
at Object.modelConfig.actions.push.func (f:\www\eliluski\node_modules\formage\lib\registry.js:220:19)
at actionDocuments (f:\www\eliluski\node_modules\formage\lib\controllers.js:219:40)
at Layer.handle as handle_request
at next (f:\www\eliluski\node_modules\formage\node_modules\express\lib\router\route.js:100:13)
at afterParseSession (f:\www\eliluski\node_modules\formage\lib\controllers.js:531:32)
at newTickHandler (f:\www\eliluski\node_modules\formage\node_modules\mpromise\lib\promise.js:234:18)
at process._tickCallback (node.js:355:11)model:
var mongoose = require('mongoose');var Schema = mongoose.Schema;var Types = Schema.Types;
var schema = new Schema({
email: { type: String, unique: true },
password: { type: String }
});
schema.methods.toString = function(){
return this.email;
};
module.exports = schema;express app:
var express = require('express');var path = require('path');var favicon = require('serve-favicon');var logger = require('morgan');var cookieSession = require('cookie-session');var bodyParser = require('body-parser');var models = require('./models');var mongoose = require('mongoose');var formage = require('formage');
var routes = require('./routes/index');
var app = express();app.set('site', 'My Site');
app.set('secret', 'secret');
app.set('mongo', process.env.MONGOLAB_URI);
// view engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'hjs');
// uncomment after placing your favicon in /public// app.use(favicon(__dirname + '/public/favicon.ico'));
app.use(logger('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: false}));
app.use(cookieSession({secret: app.get('secret'), expires: 604800000}));
app.use(express.static(path.join(__dirname, 'public')));app.use('/', routes);
formage.init(app, models, {
title: app.get('site') + ' Admin',
username: process.env.ADMIN_PASSWORD || 'admin',
password: process.env.ADMIN_USER || 'admin',
default_section: 'Configurations',
root: '/admin'
});
// catch 404 and forward to error handler
app.use(function (req, res, next) {
var err = new Error('Not Found');
err.status = 404;
next(err);
});
// error handlers
// development error handler// will print stacktraceif (app.get('env') === 'development') {
app.use(function (err, req, res, next) {
res.status(err.status || 500);
res.render('error', {
message: err.message,
error: err
});
});
}
// production error handler// no stacktraces leaked to user
app.use(function (err, req, res, next) {
res.status(err.status || 500);
res.render('error', {
message: err.message,
error: {}
});
});mongoose.connect(app.get('mongo'));
module.exports = app;@refack https://github.com/refack welcome back [image: 😄]
—
Reply to this email directly or view it on GitHub
https://github.com/TheNodeILs/formage/issues/122#issuecomment-114641040.
from formage.
Issue here as well.
from formage.
Looking into it. @robbyoconnor Which ver 2.8.2
or 3.2.21
? (and which express
mongoose
?)
from formage.
@refack -- formage 3.3.0
, express 4.14.1
, mongoose 4.8.2
from formage.
See #140 for a fix. Thank you @DamianRodziewicz!
from formage.
Related Issues (20)
- Publish new version to npm HOT 2
- Filter value generation fails for some models
- Multi-word filter values are poorly URIencoded
- External authentication
- req.body.ids in Express4 HOT 1
- Express4 and BodyParser middleware HOT 1
- Question: Readonly option only in document updates
- ReferenceError: model `User` not registered, referred by model `Article` HOT 3
- File uploading not working HOT 1
- Is this abandoned? HOT 7
- Confusing Code in ModelRegistry HOT 5
- undefined is not a function HOT 2
- populated model is not updated HOT 1
- @2.7.34 no select2 HOT 1
- default value in subarray
- Fails under node 5 on docker HOT 6
- Why don't you pin your NPM module versions? HOT 1
- Jade is deprecated, consider migrating to Pug HOT 2
- should update mongoose >= 4.7.3 due to regression in mongodb <2.2.16
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from formage.