restql_mongodb

package module
v1.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 14, 2021 License: MIT Imports: 12 Imported by: 0

README

MongoDB Plugin for RestQL

This plugin is an interface that allow RestQL to use MongoDB as data store for queries and mappings.

Building

To use this plugin you need the RestQL CLI tool. You can build a custom RestQL binary with this plugin using the following command:

$ restQL-cli build --with github.com/b2wdigital/restQL-plugin-mongodb[@version] --output ./restQL

Usage

The plugin depends on the following environment variables:

  • RESTQL_DATABASE_CONNECTION_STRING: sets the MongoDB connection string.
  • RESTQL_DATABASE_NAME: sets the MongoDB database name
  • RESTQL_DATABASE_CONNECTION_TIMEOUT: sets database connection timeout, accepts a Golang Duration string.
  • RESTQL_DATABASE_MAPPINGS_READ_TIMEOUT: sets the timeout for read mappings from the database, accepts a Golang Duration string.
  • RESTQL_DATABASE_QUERY_READ_TIMEOUT: sets the timeout for read a query from the database, accepts a Golang Duration string.

Schema

This plugin uses two collections to store the information needed by restQL.

tenant It is the collection that store mappings indexed by a tenant name. Its documents have the following schema.

{
  "_id": "MY_TENANT",
  "mappings": {
    "hero": "http://hero.api/"
  }
}

query It is the collection that store the queries. Its documents have the following schema.

{
  "name": "fetch-dc-heroes",
  "namespace": "hero-catalog",
  "revisions": [{ "text": "from hero with universe = \"DC\" " }]
}

License

The MIT license. See the LICENSE file.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewMongoDatabase

func NewMongoDatabase(log restql.Logger) (restql.DatabasePlugin, error)

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL