Giter VIP home page Giter VIP logo

mongodb-testing's Introduction

mongodb-testing

Experiments and tests on using mongodb and mongoose.

Prerequisites

  1. MongoDB
    MongoDB Community Server v4.2.0, OS Windows x64 x64 was used for this project
  2. NodeJS
    v10.15.2 was used for this project
  3. Nodemon (Optional)
    Install this utility globally if you want to monitor server updates without restarting the server:
    npm install -g nodemon

Notes

Methods of connecting to MongoDB using mongoose and mongodb (driver) are discussed in further detail in server/index.js and server/index-mongodb.js respectively. Refer to these files for references.

NOTE: mongoose looks to have ab advantage over mongodb since mongoose also has a default management system for managing MongoDB objects thru schemas and models.

Usage

  1. Create and start a local mongodb server from a local directory.

    • Set the MongoDB data path only once
      mongod --dbpath="<PATH_TO_LOCAL_DIR>"
    • (or set to mongodb's default data directory)
      mongod --dbpath=
  2. Clone this repository
    git clone https://github.com/ciatph/mongodb-testing.git

  3. Install dependencies.
    npm install

  4. Run the web server.

    • Normal command: npm run start
    • If nodemon is installed (for debugging):
      npm run dev:server
    • (Others): Run the webserver that connects to MongoDB using the mongodb driver:
      npm run dev:mongodb
  5. Follow the Querying guide for testing.

Querying

Listed are sample API endpoints for testing, available only for running index.js
(npm run start or npm run dev:server).

Cute Kittens API

  1. http://localhost:3000/kittens/create/<KITTEN_NAME>/<KITTEN_COLOR>

    • Create and save new Kitten record.
    • Replace <KITTEN_NAME> and <KITTEN_COLOR> with test values
  2. http://localhost:3000/kittens/list

    • list all saved Kitten records

Game Characters API

  1. http://localhost:3000/game/create/<CHARACTER_CLASS>/<CHARACTER_NAME>?server=<SERVER_NAME>&guild=<GUILD_NAME>

    • Create and save a new game Character record.
    • Replace the following placeholders with appropriate test values:
      • <CHARACTER_CLASS> = can either be knight, wizard or elf
      • <CHARACTER_NAME> = any String for a character name
      • <SERVER_NAME>= any String for server
      • <GUILD_NAME> = any String for guild name
  2. http://localhost:3000/game/list

    • list all saved game Character records.

mongodb-testing's People

Contributors

ciatph avatar

Stargazers

 avatar

Watchers

 avatar

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.