# <center><i class="fa fa-edit"></i> Dashboard with MongoDB </center>
###### tags: `Internship`
:::info
**Goal:**
- [x] Successfully import datasource from MongoDB
- [x] Successfully display datasource from MongoDB
- [x] Meeting with Eric
**Resources:**
[Dashboard access mongoDB from NTUST](https://hackmd.io/@eric248550/BkZpSMjc9)
[2021 物聯網平台實習 (ET2702301)](https://hackmd.io/1vqhIDkqQKqF907HpneANw?view)
[Management Portal](https://portal-mp-ensaas.education.wise-paas.com/console)
[Dashboard Home](https://dashboard-ruiguang-ews.education.wise-paas.com/?orgId=1)
[在Dashboard完成視覺化的設置](https://hackmd.io/@RenJhang/HJ_ruIxVF)
:::
### MongoDB Query
```javascript
db.raw_data.aggregate([
{"$match": {"Dispenser": "xinxing07" }},
{"$project": {"Water": "$Choose", "Dispenser": "$Dispenser","WaterTemp": "$WaterTemp","Time": "$Timming", "CardID": "$CardID", "WaterVolume": "$WaterVolume"}}
]);
```
:::danger
This syntax produced an error. Tried using aggregate instead.
:::
```javascript
db.raw_data.aggregate([
{"$match": {"Dispenser": "xinxing08", "Timming_ISO":{ "$gte" : "$from", "$lt": "$to" } }},
{"$project": {"ts": "$Timming_ISO", "Water": "$Choose", "Dispenser": "$Dispenser","WaterTemp": "$WaterTemp", "CardID": "$CardID", "value": "$WaterVolume"}}
]);
```
:::danger
Still produced an error. Needed to be changed from a table to a timeseries
:::

### Meeting with Eric
- fixed syntax(can't be changed)
- `"Timming_ISO":{ "$gte" : "$from", "$lt": "$to" }`
- `"ts": "$Timming_ISO"`
- Grafana Rule:
- The time(x-axis) should be "ts" column
- the value(y-axis) should be "value" column
- only use aggregate
- example syntax
- Find the data in **raw_data** collection
- filter the data only find if column "Dispenser" is "xinxing08"
- set the value(y-axis) to "$WaterVolume"
```javascript
db.raw_data.aggregate([
{"$match": {"Dispenser": "xinxing08", "Timming_ISO":{ "$gte" : "$from", "$lt": "$to" } }},
{"$project": {"ts": "$Timming_ISO", "Water": "$Choose", "Dispenser": "$Dispenser","WaterTemp": "$WaterTemp", "CardID": "$CardID", "value": "$WaterVolume"}}
]);
```
**To Do List**
- [ ] Explore and create different dashboards with current water dispenser data
- [ ] End goal is to transfer Thingworx to WISE-PaaS
- [ ] Try to utilize a drop down menu feature in the graphs created