Git Product home page Git Product logo

nested-categories's Introduction

Nested Categories & Products

This is a small API that models Products (shirt, sneakers, television, etc.) and Categories (Clothing, Shoes, Electronics, etc.)

  • Categories may be nested (Clothings -> Shirts -> T-Shirts)
  • Products may be in multiple categories
  • Categories can contain multiple products

Run the code

The dev server runs on port 4000. This will use docker-compose to spin up the api as well as a mongo container to store the data.

cd api
npm install
npm run dev

You can play with the endpoints manually or run the demo script to see all of the CRUD operations used. After starting the dev server, open up another terminal and run the following

cd api
npm run demo

API

POST /category - add a category

GET /category - get all categories

POST /product - add product

GET /product?category=xxx - get all products in category

PATCH /product/:id - update a product

Built with

  • Node.js
  • Express
  • Mongo
  • Docker

nested-categories's People

Contributors

jgdodson avatar

Watchers

 avatar

nested-categories's Issues

Initial Features

Setup

  • mongo container in docker-compose
  • establish db connection

API

  • POST /category - add a category
  • GET /category - get all categories with child categories mapped to it
  • POST /product - add product, mapped to categories
  • GET /product?category=123 - get all products in category
  • PATCH /product - update product details

Data model

  • Use the 'child references' model for category tree

Category

{
  "_id": "Category1",
  "children": ["Category2", "Category3"]
}

Product

{
  "_id": "Product1",
  "name": "socks",
  "categories": ["Category1", "Category3"]
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.