This service can be added to your project by visiting Mia-Platform Marketplace and creating a new microservice from the CRUD Service plugin.
Configure a CRUD Service to use MongoDB CRUD section
In order to start using the MongoDB CRUD section, all you have to do is adding it from the Marketplace: all the ConfigMaps and environment variables it needs will be precompiled with no need to change them.
The CRUD Service supports custom CA certs. If you want to learn more about these certificates and how to configure them in your CRUD Service, visit this page.
The CRUD Service default ConfigMap is mounted in
/home/node/app/collections. You can freely choose its name during the service creation.
Furthermore, the ConfigMap is not editable, as it is fundamental for the MongoDB CRUD section to work. It is not possible to add files, edit the mountPath, or delete it.
However, you will find a link that will redirect you to MongoDB CRUD dedicated section where you can continue to configure your project CRUDs. By doing so, you will automatically define the collections that will be handled by the service, which means that there is no need to add any configuration files.
Below you can find all the environment variables that you can edit.
|MONGODB_URL||String||Required||-||The MongoDB connection string. It must contain the database name on which the collections will be managed.|
|COLLECTION_DEFINITION_FOLDER||String||Required||The path to the folder where all collections are defined.|
|VIEWS_DEFINITION_FOLDER||String||Required||The path to the folder where all views are defined.|
|USER_ID_HEADER_KEY||String||Required||-||Header key used to know which user makes the request. User id is useful to add |
|CRUD_MAX_LIMIT||Integer||Optional||200||Configures the maximum limit of objects returned by a MongoDB query.|
|CRUD_LIMIT_CONSTRAINT_ENABLED||Boolean||Optional||Enables the query limit constraint feature. If set to |
|TRUSTED_PROXIES||String||Optional||Contains the trusted proxies values.|
|HTTP_PORT||String||Optional||-||The port exposed by the service.|
|LOG_LEVEL||String||Optional||Level of the log. It can be one of the following: |
|EXPOSE_METRICS||Boolean||Optional||Specifies if Prometheus metrics should be exposed or not.|
|ALLOW_DISK_USE_IN_QUERIES||Boolean||Optional||-||Sets the |
|ENABLE_TRACING||Boolean||Optional||Specifies if OpenTelemetry tracing should be enabled. It is possible to find more documentation here|
|ENABLE_STRICT_OUTPUT_VALIDATION||Boolean||Optional||Specifies whether service responses should be strict compliant with the schema (when enabled the service would fail to return values in case underlying collection contains documents not compliant with the schema)|
|MAX_MULTIPART_FILE_BYTES||Number||Optional||100||Sets the max size (Mb) that is possible to process in multipart requests|
ALLOW_DISK_USE_IN_QUERIES (either with
false values) with a MongoDB version lower than 4.4 will make all the GET calls unusable since the MongoDB cluster will raise an error for the unrecognized option
It is also important to notice that starting from MongoDB v6.0 new server property
is introduced with its value set to
true by default. Consequently, the default behavior for that MongoDB version
is that for queries with pipeline stages using more than 100 MB of memory to execute, the database automatically
write temporary files on disk to support those queries.
This default behavior can be disabled for all queries by setting
In case you want to use Client Side Field Level Encryption, you should also include several specific Environment Variables, either you are using the encryption with Google Platform Cloud or a local key.