3
mongoose = require 'mongoose'
class Locations
constructor: @(host, port) ->
@db = new mongoose 'locations', new Server(host, port, {auto_reconnect: true}, {})
this.db.open ->
null
getAll: (callback) ->
@db.collection 'locations', (err, locations_collection) ->
if err?
callback err
else
callback null, locations_collection
null
exports.Locations = Locations
내가 파일에 내 app.js
에 locations.coffee
와라는 것을 가지고, 나는MongoDB를 사용하여 Node.js에서`model`을 정의하는 적절한 방법은 무엇입니까?
locationsModel = require '../models/locations'
locationModel = new locationsModel 'localhost', 27017
을하지만
node.js:134
throw e; // process.nextTick error, or 'error' event on first tick
^
ReferenceError: host is not defined
나는 모든 파일을 넣을 파일이 무엇인지 궁금합니다. – Shamoon