Code Monkey home page Code Monkey logo

springboot-mongodb-rest's Introduction

Getting Started

Reference Documentation

For further reference, please consider the following sections:

Guides

The following guides illustrate how to use some features concretely:

Additional Links

These additional references should also help you:

Install MongoDB locally on Mac

  1. Download MongoDB MongoDB Community Server image

  2. Setup MONGO_HOME environment variable image

  3. Check mongo version in command prompt/Terminal

mongo --version image

  1. Setting Database Server : Create a folder or directory which will store all the data processed by the mongod

mongod --dbpath /Users/sovanmukherjee/dev/Software/mongodb image

  1. Install mongoDb Compass to see collection and data image

After installation open MongoDB Campass image

  1. Click on Fill in connection fields image

  2. Provide all required information and click on connect image

image

  1. You can create database and Collection manually

image

image

  1. Check all databases through command prompt

mongo

show dbs image

  1. Use database with database name

Syntax: use <DB_NAME> image

  1. Create index

Syntax: db.COLLECTION_NAME.createIndex({KEY:1})

db.student.createIndex({"crTime": 1})

  1. View index

Syntax: db.COLLECTION_NAME.getIndexes()

db.student.getIndexes()

image

Add TTL on mongoDB

  1. create TTL Index

Syntax: db.COLLECTION_NAME.createIndex({"KEY": 1},{expireAfter: "3600s"})

-OR -

db.COLLECTION_NAME.createIndex( { "KEY": 1 }, { expireAfterSeconds: 3600 } )

Example: db.student.createIndex({"crTime": 1},{expireAfter: "3600s"})

image

Run Application

Local Swagger UI: http://localhost:8080/swagger-ui/index.html image

Save Student

image

You can check data in Compass

image

image

Get Students By className

Request payload image Response payload

{
  "content": [
    {
      "id": "1971a4ab-5226-4f81-b3fc-ffde69aa8277",
      "rollNumber": 1,
      "contact": {
        "emailId": "[email protected]",
        "mobile": "9999999999"
      },
      "vsningFlds": {
        "createdBy": "abc",
        "crTime": "2022-09-24T22:34:11.826"
      }
    },
    {
      "id": "cdb5d2e7-36ee-40c8-bc66-6eefa5b7d503",
      "rollNumber": 2,
      "contact": {
        "emailId": "[email protected]",
        "mobile": "9999999999"
      },
      "vsningFlds": {
        "createdBy": "abc",
        "crTime": "2022-09-24T22:37:47.863"
      }
    },
    {
      "id": "a3fc979f-3835-4e19-a374-8ca849711144",
      "rollNumber": 3,
      "contact": {
        "emailId": "[email protected]",
        "mobile": "9999999999"
      },
      "vsningFlds": {
        "createdBy": "abc",
        "crTime": "2022-09-24T22:38:19.39"
      }
    },
    {
      "id": "db30ce97-d29b-437f-b754-15354ef8b861",
      "rollNumber": 4,
      "contact": {
        "emailId": "[email protected]",
        "mobile": "9999999999"
      },
      "vsningFlds": {
        "createdBy": "abc",
        "crTime": "2022-09-24T22:39:24.644"
      }
    },
    {
      "id": "c71bc980-1476-474f-a709-43bd1a28f20a",
      "rollNumber": 5,
      "contact": {
        "emailId": "[email protected]",
        "mobile": "9999999999"
      },
      "vsningFlds": {
        "createdBy": "abc",
        "crTime": "2022-09-24T22:39:50.437"
      }
    }
  ],
  "pageable": {
    "sort": {
      "empty": false,
      "sorted": true,
      "unsorted": false
    },
    "offset": 0,
    "pageNumber": 0,
    "pageSize": 10,
    "paged": true,
    "unpaged": false
  },
  "last": true,
  "totalPages": 1,
  "totalElements": 5,
  "first": true,
  "size": 10,
  "number": 0,
  "sort": {
    "empty": false,
    "sorted": true,
    "unsorted": false
  },
  "numberOfElements": 5,
  "empty": false
}

springboot-mongodb-rest's People

Contributors

sovanmukherjee 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.