sai-storage-mongo

command module
v1.1.5 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2025 License: MIT Imports: 7 Imported by: 0

README

Microservice mongo storage

Ports

8880: HTTP
8881: WebSocket
8882: Socket

How to run

make build: rebuild and start service
make up: start service
make down: stop service
make logs: display service logs

API requests

CREATE

Create multiple documents in a collection

curl --request GET \
  --url http://localhost:8880/ \
  --header 'Content-Type: application/json' \
  --data '{
	"method": "create",
	"data": {
		"collection": "CollectionName",
		"documents": [{}], //<- array of structs to save in a DB
	}
}'
READ

Return filtered documents. Can be paginated with skip\limit.

curl --request GET \
  --url http://localhost:8880/ \
  --header 'Content-Type: application/json' \
  --data '{
	"method": "read",
	"data": {
		"collection": "CollectionName",
		"select":{} //<-mongo select request format
	},
	"metadata": {
	   "skip": 10, //<- to skip first 10 elements
	   "limit": 10, //<- to limit result with 10 items
	   "count": 1 //<- to have total count in the result without pagination data
	}
}'
UPDATE / UPSERT

Update: update all filtered documents. Upsert: update all or create a new document if nothing to update.

curl --request GET \
  --url http://localhost:8880/ \
  --header 'Content-Type: application/json' \
  --data '{
	"method": "update", //<- Or "upsert"
	"data": {
		"collection": "CollectionName",
		"select":{} //<-mongo select request format,
		"document": {}, //<- struct to save in a DB Example: "document": { "$set" : {"field":"value"}  }
	}
}'
DELETE

Delete all filtered documents.

curl --request GET \
  --url http://localhost:8880/ \
  --header 'Content-Type: application/json' \
  --data '{
	"method": "delete",
	"data": {
		"collection": "CollectionName",
		"select":{} //<-mongo select request format
	}
}'

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
external

Jump to

Keyboard shortcuts

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