I stored my Mongo
data in mLab.com
with numerous collections, visible in the image below:
https://i.sstatic.net/lXSfx.png
I am unable to access the "requests" collection. Here are the steps I've taken:
Firstly, I connected to the database and set up the function in the main process (main.js
):
mongoose.connect('url', { useMongoClient: true });
ipcMain.on('load-requests', function(event) {
return Requests.find({}, { sort: {createdAt: -1}});
});
In a separate file named schema.js
, I have the following:
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);
Within the renderer process (homePage.html
), I have this content:
<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>
I aim to access page-inner
via its id
and update the attributes based on the data retrieved from the load-requests
function in the main process.
What is the best way to display these attributes within homePage.html
?