Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/tutosrive/ferreandina-nosql/llms.txt

Use this file to discover all available pages before exploring further.

The Branch resource represents a physical Ferreandina hardware store location. Each branch document stores the branch name, city, street address, main-branch flag, and a cover image URL. Two embedded arrays are maintained directly inside the branch document: a products array capturing current inventory (product ID, name, quantity, and image) and a workers array listing staff assigned to that branch (worker ID, name, and image). All CRUD operations are available at /api/branches. Four additional aggregation-based queries (city lookups, inventory reports, and more) are also supported — see Advanced Queries.

Document Schema

_id
integer
required
Unique integer identifier for the branch.
name
string
required
Slug-style name for the branch (e.g., "ferreandina-manizales").
city
string
required
City where the branch is located (e.g., "manizales").
direction
string
required
Street address of the branch (e.g., "Cra 3 #23-12").
is_main
boolean
required
Whether this is the main/headquarters branch.
image
string
required
URL of the branch cover image.
products
array
required
Embedded array of products currently stocked at this branch.
workers
array
required
Embedded array of workers assigned to this branch.

Endpoints

GET /api/branches

Returns an array of all branch documents.
curl http://localhost:7070/api/branches
[
  {
    "_id": 1,
    "name": "ferreandina-manizales",
    "city": "manizales",
    "direction": "Cra 3 #23-12",
    "is_main": false,
    "image": "https://cdn.jsdelivr.net/gh/tutosrive/images-projects-srm-trg@main/others/ferreandina-nosql/branches/ferreandina-manizales.webp",
    "products": [ "..." ],
    "workers": [ "..." ]
  }
]

GET /api/branches/{id}

Returns a single branch by its integer _id.
curl http://localhost:7070/api/branches/1
{
  "_id": 1,
  "name": "ferreandina-manizales",
  "city": "manizales",
  "direction": "Cra 3 #23-12",
  "is_main": false,
  "image": "https://cdn.jsdelivr.net/gh/tutosrive/images-projects-srm-trg@main/others/ferreandina-nosql/branches/ferreandina-manizales.webp",
  "products": [
    {
      "_id": 1,
      "name": "hammer",
      "quantity": 10,
      "image": "https://cdn.jsdelivr.net/gh/tutosrive/images-projects-srm-trg@main/others/ferreandina-nosql/products/hammer.webp"
    }
  ],
  "workers": [
    {
      "_id": 1,
      "name": "Eduardo Sánchez",
      "image": "https://cdn.jsdelivr.net/gh/tutosrive/images-projects-srm-trg@main/others/ferreandina-nosql/workers/1.jpg"
    }
  ]
}

POST /api/branches

Creates a new branch. Send all required fields as a JSON body. Request Body
_id
integer
required
Unique integer ID for the new branch.
name
string
required
Slug-style branch name.
city
string
required
City of the branch.
direction
string
required
Street address of the branch.
is_main
boolean
required
Set true if this is the headquarters branch.
image
string
URL for the branch cover image.
products
array
Initial embedded product inventory array.
workers
array
Initial embedded worker array.
curl -X POST http://localhost:7070/api/branches \
  -H "Content-Type: application/json" \
  -d '{
    "_id": 2,
    "name": "ferreandina-bogota",
    "city": "bogota",
    "direction": "Calle 72 #10-34",
    "is_main": true,
    "image": "https://example.com/bogota.webp",
    "products": [],
    "workers": []
  }'
{ "insertedId": 2 }

PATCH /api/branches/{id}

Partially updates an existing branch. Only include the fields you want to change. Request Body
name
string
Updated branch name.
city
string
Updated city.
direction
string
Updated street address.
is_main
boolean
Updated main-branch flag.
image
string
Updated cover image URL.
products
array
Replacement products array.
workers
array
Replacement workers array.
curl -X PATCH http://localhost:7070/api/branches/1 \
  -H "Content-Type: application/json" \
  -d '{ "direction": "Cra 5 #45-20" }'
{ "modifiedCount": 1 }

DELETE /api/branches/{id}

Deletes the branch with the given integer _id.
curl -X DELETE http://localhost:7070/api/branches/1
{ "deletedCount": 1 }

Special Endpoints

Four additional query endpoints exist for branches (city filtering, inventory aggregations, and more). See Advanced Queries for the full reference.

Example Document

{
  "_id": 1,
  "name": "ferreandina-manizales",
  "city": "manizales",
  "direction": "Cra 3 #23-12",
  "is_main": false,
  "image": "https://cdn.jsdelivr.net/gh/tutosrive/images-projects-srm-trg@main/others/ferreandina-nosql/branches/ferreandina-manizales.webp",
  "products": [
    {
      "_id": 1,
      "name": "hammer",
      "quantity": 10,
      "image": "https://cdn.jsdelivr.net/gh/tutosrive/images-projects-srm-trg@main/others/ferreandina-nosql/products/hammer.webp"
    },
    {
      "_id": 3,
      "name": "power_drill",
      "quantity": 4500,
      "image": "https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcQabipjJj6zlLRVhlf8dq6SNxXqeyfGTFRu20wY_kaSZfhmzl1CzisyBZNKrUUW"
    },
    {
      "_id": 4,
      "name": "drywall_screws",
      "quantity": 6500,
      "image": "https://encrypted-tbn2.gstatic.com/images?q=tbn:ANd9GcQi8_UnoQjJPtKL3J0IGaWxtNTU9WCyoesNjaAf-Q4dbkwD1TCh7HKVUDvH2JL5"
    },
    {
      "_id": 5,
      "name": "copper_wire_12awg",
      "quantity": 2300,
      "image": "https://encrypted-tbn1.gstatic.com/images?q=tbn:ANd9GcRSeOJ-CxlNs5ztlkT-_cOfG3Rpwu56JL_hR8Us67qji9uweafOVFqeaRCowpEU"
    }
  ],
  "workers": [
    {
      "_id": 1,
      "name": "Eduardo Sánchez",
      "image": "https://cdn.jsdelivr.net/gh/tutosrive/images-projects-srm-trg@main/others/ferreandina-nosql/workers/1.jpg"
    },
    {
      "_id": 2,
      "name": "Santiago Marin",
      "image": "https://cdn.jsdelivr.net/gh/tutosrive/images-projects-srm-trg@main/others/ferreandina-nosql/workers/2.jpg"
    }
  ]
}

Build docs developers (and LLMs) love