GitXplorerGitXplorer
S

mongodb-example

public
1 stars
0 forks
0 issues

Commits

List of commits on branch master.
Unverified
2782a5a0a3a47d2dab2a8fa6210dc5e6e474f8eb

docs: 📝 Add how to test Mongo from terminal

SSergioGasquez committed 2 years ago
Unverified
0f90f0b111d7be2049338c9aad7681ce4f9868b3

chore: 🎨 Sort dependencies

SSergioGasquez committed 2 years ago
Unverified
b1b1bf6091b98ce3282bb256e7ed764c8a9a842c

docs: 📝 Update documentation

SSergioGasquez committed 2 years ago
Unverified
ac53a4a75266fa8746d599d74c945549889ed6ff

docs: 📝 Update readme

SSergioGasquez committed 2 years ago
Unverified
f2cfed0ce854329d35d6492fc49c0336a82eed3e

ci: 🔥 Remove duplicated CI

SSergioGasquez committed 2 years ago
Verified
5df3669e86133347bb3959f69b1f4c2c53e06598

Create CI.yml

SSergioGasquez committed 2 years ago

README

The README file for this repository.

MongoDB example

CI

Simple example built for esp-rust-board that sends temperature and humidity to MongoDB, using POST method.

MongoDB Collection

To reproduce the example

  1. Setup MongoDB:
    1. Create an application
    2. Create a database
    3. Create a collection
  2. Rename cfg.toml.example to cfg.toml
  3. Fill the cfg.toml with:
    1. wifi_ssid: Wifi SSID
    2. wifi_pass: Wifi password
    3. api_key: MongoDB API Key
    4. data_source: MongoDB Data Source
    5. database: MongoDB Database name
    6. collection: MongoDB Collection name
    7. app_id: MongoDB App ID

Testing MongoDB from terminal

To publish data into your collection using curl:

curl https://data.mongodb-api.com/app/<app_id>/endpoint/data/v1/action/insertOne \
    -H 'Content-Type: application/json' \
    -H 'api-key: <api_key>' \
    --data-raw \
    '{
  "dataSource": "<data_source>",
  "database" : "<data_base>",
  "collection" : "<collection>",
  "document" : { "name": "Harvest",
                 "breed": "Labrador",
                 "age": 5 }
}'

For more information, see MongoDB documentation

Dev Containers

This repository offers Dev Containers supports for:

Note

In order to use GitHub Codespaces the project needs to be published in a GitHub repository and the user needs to be part of the Codespaces beta or have the project under an organization.

If using VS Code or GitHub Codespaces, you can pull the image instead of building it from the Dockerfile by selecting the image property instead of build in .devcontainer/devcontainer.json. Further customization of the Dev Container can be achived, see .devcontainer.json reference.

When using Dev Containers, some tooling to facilitate building, flashing and simulating in Wokwi is also added.

Build

  • Terminal approach:

    scripts/build.sh  [debug | release]
    

    If no argument is passed, release will be used as default

  • UI approach:

    The default build task is already set to build the project, and it can be used in VS Code and GitHub Codespaces:

    • From the Command Palette (Ctrl-Shift-P or Cmd-Shift-P) run the Tasks: Run Build Task command.
    • Terminal-> Run Build Task in the menu.
    • With Ctrl-Shift-B or Cmd-Shift-B.
    • From the Command Palette (Ctrl-Shift-P or Cmd-Shift-P) run the Tasks: Run Task command and select Build.
    • From UI: Press Build on the left side of the Status Bar.

Flash

Note

When using GitHub Codespaces, we need to make the ports public, see instructions.

  • Terminal approach:

    • Using flash.sh script:

      scripts/flash.sh [debug | release]
      

      If no argument is passed, release will be used as default

  • UI approach:

    • From the Command Palette (Ctrl-Shift-P or Cmd-Shift-P) run the Tasks: Run Task command and select Build & Flash.
    • From UI: Press Build & Flash on the left side of the Status Bar.
  • Any alternative flashing method from host machine.

Wokwi Simulation

VS Code Dev Containers and GitHub Codespaces

The Dev Container includes the Wokwi Vs Code installed, hence you can simulate your built projects doing the following:

  1. Press F1
  2. Run Wokwi: Start Simulator

Note

We assume that the project is built in debug mode, if you want to simulate projects in release, please update the elf and firmware proprieties in wokwi.toml.

For more information and details on how to use the Wokwi extension, see Getting Started and Debugging your code Chapter of the Wokwi documentation.