4
獲得集合名字,我有一個貓鼬模型像這樣:如何從貓鼬模型對象
var mongoose = require("mongoose");
var Schema = mongoose.Schema;
let schema = new Schema({
test: String
}, {
collection: "test"
});
let model = mongoose.model("TestModel", schema);
我如何獲取集合名稱,如果在回調中我只能訪問「模型」的參考。
期待這樣的:
model.getCollectionName();
'model.collection.name' also works – zhirzh