0.2.5 • Published 25 days ago

@flair-sdk/solution-database-mongodb v0.2.5

Weekly downloads
-
License
MIT
Repository
-
Last release
25 days ago

MongoDB Database Integration

Flair

This package provides components required to sync indexed data to a MongoDB instance in Flair indexer.

Installation

  1. Make sure you have created your indexing cluster as described in Getting Started.

  2. Install the MongoDB solution package:

pnpm install @flair-sdk/solution-database-mongodb
  1. Define your schemas based on your entities. For example, if you have a Swap entity, you can define a schema as follows:
# ./src/schemas/Swap.yml
---
Swap:
  entityId: STRING
  entityUpdatedAt: INT64
  chainId: INT64
  poolAddress: STRING
  from: STRING
  to: STRING
  amount: INT256
  amountUSD: DOUBLE
  someObjectOrArray: STRING # all json stringified objects or arrays will be automatically stored as acttual nested documents/arrays in mongo
  1. Add the MongoDB solution to your manifest.yml.mustache usually created from starter-boilerplate repository:
# ./manifest.yml.mustache
# ...
solutions:
  - source: '@flair-sdk/solution-database-mongodb'
    config:
      schema:
        - src/schemas/*.yml
      connectionUri: '{{{ mongoUri }}}'
      databaseName: flair

The "mongoUri" here is a variable that is replaced by mustache locally. Refer to boilerplate repo for more details.

  1. Add mongoUri to your config.json usually created from starter-boilerplate repository:
// ./config.prod.json
{
  "cluster": "prod",
  "namespace": "my-project",
  // ...
  "mongoUri": "{{ secret(\"mongodb.uri\") }}"
}

The "mongodb.uri" is an actual secret value set using flair secret command, so that it is not exposed in the repository.

  1. Deploy your cluster and check the status of real-time live syncing.
pnpm generate-and-deploy
pnpm flair logs -w -t component=enricher
  1. (OPTIONAL) If there are any historical previously indexed data, you can sync them using:
pnpm flair script database-manual-full-sync
0.2.5

25 days ago

0.2.4

25 days ago

0.2.1

1 month ago

0.2.0

1 month ago

0.2.3

1 month ago

0.2.2

1 month ago

0.1.6

2 months ago

0.1.4

2 months ago

0.1.3

2 months ago

0.1.5

2 months ago

0.1.1

2 months ago

0.1.0

2 months ago

0.0.14

2 months ago

0.0.13

2 months ago

0.0.12

2 months ago

0.0.11

2 months ago

0.0.10

2 months ago

0.0.9

2 months ago

0.0.8

2 months ago

0.0.7

2 months ago

0.0.6

2 months ago

0.0.5

2 months ago

0.0.4

2 months ago

0.0.2

2 months ago

0.0.1

2 months ago