これは私のlocationsModel.js
ファイルです:私のコントローラで私のマングースモデルはなぜロードされませんか?
var LocationSchema, LocationsSchema, ObjectId, Schema, mongoose;
mongoose = require('mongoose');
Schema = mongoose.Schema;
ObjectId = Schema.ObjectId;
LocationSchema = {
latitude: String,
longitude: String,
locationText: String
};
LocationsSchema = new Schema(LocationSchema);
LocationsSchema.method({
getLocation: function(callback) {
return console.log('hi');
}
});
exports.Locations = mongoose.model('Locations', LocationsSchema, 'locations');
、私が持っている:
var Locations, mongoose;
mongoose = require('mongoose');
Locations = require('../models/locationsModel').Locations;
exports.search = function(req, res) {
var itemText, locationText;
Locations.getLocation('info', function(err, callback) {
return console.log('calleback');
});
return;
};
私はそれを実行すると、私は次のエラーを取得する:
TypeError: Object function model() {
Model.apply(this, arguments);
} has no method 'getLocation'
私は何行方不明?
;'あなたは、単に行くことができます'Locations = mongoose.model( 'Locations')' –