Back to Poem

MongoDB Example

examples/poem/mongodb/README.md

2.0.0904 B
Original Source

MongoDB Example

Basic integration MongoDB in poem

Usage

Available Routes

GET /user

Query users from MongoDB.

json
[
    {
        "_id": {
            "$oid": "614f73c715681cf389fa93f9"
        },
        "name": "JungWoo",
        "email": "[email protected]",
        "age": 19
    },
    {
        "_id": {
            "$oid": "614f75e67ade426aa3f73b1c"
        },
        "name": "Jack",
        "email": "[email protected]",
        "age": 19
    }
]

POST /user

Inserts a new user into the MongoDB.

Provide a JSON payload with a name. Eg:

json
{
    "name": "JungWoo",
    "email": "[email protected]",
    "age": 19
}

On success, a response like the following is returned:

json
{
    "_id": {
        "$oid": "614f73c715681cf389fa93f9"
    },
    "name": "JungWoo",
    "email": "[email protected]",
    "age": 19
}