我能够在交互式 node
session 中加载 Mongoose 并像这样查看其 connect
方法...
> var mongoose = require("mongoose/");
> mongoose.connect
[Function]
...但是当通过 Browserify 加载 Mongoose 时,该方法丢失了。以下代码...
var mongoose = require("mongoose/");
console.log(mongoose);
...在 Chrome 中记录以下内容:
Object {Error: function, Schema: function, Types: Object, VirtualType: function, SchemaType: function…}
Document: function Document(obj, schema, fields, skipId, skipInit) {
Error: function MongooseError(msg) {
Schema: function Schema(obj, options) {
SchemaType: function SchemaType(path, options, instance) {
Types: Object
VirtualType: function VirtualType(options, name) {
utils: Object
__proto__: Object
我想我正在做一些相对愚蠢的事情,但对于我的生活我无法确定是什么。 This question is similar ,但建议的解决方案无法解决我的问题。
最佳答案
浏览器中的 Mongoose 不会公开大多数在 node.js 中使用时可用的方法。您可以使用它来创建模式并根据模式验证对象,仅此而已。
关于javascript - Mongoose 在通过 Browserify 加载时没有连接方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30018242/