我想用Nodejs,Express和Georedis设置MVC模式,我已将所有必需的模块包含在config/require_module.js
下的单个文件中作为 -
var all_modules = {};
all_modules.express = require('express');
all_modules.router = all_modules.express.Router();
all_modules.redis = require('redis');
all_modules.client = all_modules.redis.createClient();
all_modules.georedis = require('georedis');
all_modules.fs = require('fs');
all_modules.mysqlPool = require('./myqlConn');
all_modules.locationsController = require('./../controllers/locations');
module.exports = all_modules;
在controller/locations.js
中,我将此文件包含为 -
`var allModules = require('./../config/require_module');`
我把georedis模块称为 -
exports.update_location = function(req, res) {
var geo = allModules.georedis.initialize(allModules.client, {
zset: 'LocationsSet',
nativeGeo: false
});
};
但它正在抛出异常 -
TypeError: Cannot read property 'initialize' of undefined
<br> at exports.update_location (/var/www/html/nodeRedisRestexample/controllers/locations.js:27:34)
locations.js第27行是
var geo = allModules.georedis.initialize(allModules.client, {
请帮忙。谢谢