Как определить методы в модели мангели?

Мои 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'
37
задан royhowie 30 June 2015 в 20:47
поделиться