Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add db update calls #5

Open
dankelleher opened this issue May 31, 2023 · 0 comments
Open

Add db update calls #5

dankelleher opened this issue May 31, 2023 · 0 comments

Comments

@dankelleher
Copy link
Member

For simplicity, and to avoid dependencies, we are taking advantage of Mongo's HTTP API to update the DB.

This API update is currently not in place in the existing code.

To post a transfer (a mint in this case) to the DB:

curl --request POST \
  --url https://data.mongodb-api.com/app/data-vhksk/endpoint/data/v1/action/insertOne \
  --header 'Content-Type: application/json' \
  --header 'api-key: XXX' \
  --data '{
      "dataSource": "Cluster0",
      "database": "gsol-tracker",
      "collection": "mints2",
      "document": {
        "timestamp": { "$date": {"$numberLong": "1675768427000" }},
        "recipient": "48V9nmW9awiR9BmihdGhUL3ZpYJ8MCgGeUoSWbtqjicv",
                "amount": 1000000000
      }
  }'

Transfers are identical, but the collection is "transfers2" and there is an additional sender field

and to get the data (use this for testing and debugging):

curl --request POST \
  --url https://data.mongodb-api.com/app/data-vhksk/endpoint/data/v1/action/find \
  --header 'Content-Type: application/json' \
  --header 'api-key: XXX' \
  --data '{
    "dataSource": "Cluster0",
    "database": "gsol-tracker",
    "collection": "transfers2",
    "filter": {
        "$or": [
            {
                "recipient": "48V9nmW9awiR9BmihdGhUL3ZpYJ8MCgGeUoSWbtqjicv"
            },
            {
                "sender": "48V9nmW9awiR9BmihdGhUL3ZpYJ8MCgGeUoSWbtqjicv"
            }
        ]
    }
}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant