我的locationsModel
文件:
mongoose = require 'mongoose'
threeTaps = require '../modules/threeTaps'
Schema = mongoose.Schema
ObjectId = Schema.ObjectId
LocationSchema =
latitude: String
longitude: String
locationText: String
Location = new Schema LocationSchema
Location.methods.testFunc = (callback) ->
console.log 'in test'
mongoose.model('Location', Location);
我使用以下代码进行调用:
myLocation.testFunc {locationText: locationText}, (err, results) ->
但我收到一个错误:
TypeError: Object function model() {
Model.apply(this, arguments);
} has no method 'testFunc'
var Animal = mongoose.model('Animal', animalSchema);
Animal.findByName('fido', function (err, animals) {console.log(animals)}); - Wax Cage