我在mLab.com中托管了我的Mongo数据库,其中有几个集合,如下图所示:

我似乎无法访问"requests“集合。以下是我所做的工作:
首先,我连接到数据库并在主进程(main.js)中创建函数:
mongoose.connect('url', { useMongoClient: true });
ipcMain.on('load-requests', function(event) {
return Requests.find({}, { sort: {createdAt: -1}});
});在另一个名为schema.js的文件中,我有以下内容:
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
var hosSchema = new Schema({
hospital: String,
state: String,
reasons: String,
requestedDateTime: String,
requestNumber: String,
status: String,
});
module.exports = mongoose.model('Requests', hosSchema);在渲染器进程(homePage.html)中,我有以下内容:
<div id="page-inner">
<div class="row">
<div class="col-md-4 col-sm-4">
<div class="card teal">
<div class="card-content white-text">
<span class="card-title">state</span>
<p>reason</p>
</div>
<div class="card-action">
<a href="#">requestNumber</a>
<a href="#">requestedDateTime</a>
</div>
</div>
</div>
</div>
</div>我想通过page-inner的id访问它,并在数据库中将属性更改为相关的属性。例如,应该使用从主进程(load-requests)中的函数检索到的属性来更改状态。
如何在homePage.html中显示属性
发布于 2017-08-05 13:47:17
在Schema.js中:
var hosSchemaModel = mongoose.model('Requests', hosSchema);
module.exports = hosSchemaModel;在main.js中:
var hosSchemaModel = require("./Schema.js");
var getHosSchemas = function () {
hosSchemaModel.find({}, function (err, hosSchema) {
if (err) {
//...
} else {
//Do something with the hosSchema
}
});
}https://stackoverflow.com/questions/45518257
复制相似问题