Coder Social home page Coder Social logo

arunbandari / mongo-gui Goto Github PK

View Code? Open in Web Editor NEW
269.0 269.0 79.0 30.28 MB

A web-based MongoDB graphical user interface

Home Page: http://20.106.238.56:4321/

License: MIT License

JavaScript 20.24% HTML 26.28% TypeScript 44.83% CSS 8.41% Dockerfile 0.21% Shell 0.04%
angular gui mongodb nodejs npm-package user-interface

mongo-gui's Introduction

npm version Known Vulnerabilities GitHub stars

Mongo GUI

A web-based MongoDB graphical user interface.

Demo

Read-only demo: http://20.106.238.56:4321/

Mongo GUI Features

  • Connect to local/remote mongodb instances
  • View/add/delete databases
  • View/add/delete collections
  • View/add/update/delete/copy documents
  • Multi tab support
  • Query documents
  • Advanced pagination
  • Supports all BSON types in documents
  • Rich user interface
  • Import CSV or JSON files
  • Export collection to CSV or JSON files
  • Authentication
  • "Natural Language Querying" or "AI-Powered Querying".

How to install and run MongoDB GUI

The following are the different ways to install mongo-gui.

From npm:

  • Install the module globally using the command npm install -g mongo-gui
  • Then use the command mongo-gui to run the application

From github:

  • First of all, clone the mongo-gui repository using the command git clone https://github.com/arunbandari/mongo-gui or download the zip file from here.
  • Change the directory to mongo-gui cd mongo-gui
  • Install all the dependencies npm install
  • Start the application using either npm start or node server.js command

Note: Node.js must be installed on your machine to run this application

From Docker Hub:

Docker compose

version: '3'

services:
  mongo-gui:
    container_name: "mongo-gui"
    image: ugleiton/mongo-gui
    restart: always
    ports:
      - "4321:4321"
    environment:
      - MONGO_URL=mongodb://localhost:27017

Mongo GUI Usage

The commands mongo-gui and npm start or node server.js start the application with the following configuaration:

  • URL (-u): mongodb://localhost:27017

  • PORT (-p): 4321

    and the application will be accesible at http://localhost:4321

To connect to any other mongodb instance, pass mongo connection string as an argument, eg:

  • Installed via npm: mongo-gui -u mongodb+srv://<username>:<password>@host/<dbnames>?retryWrites=true&w=majority'

  • Installed via github: (npm start --/node server.js) -u mongodb+srv://<username>:<password>@host/<dbnames>?retryWrites=true&w=majority'

Available options:

  • -u: url, mongo-gui tries to connect to this mongodb instance
  • -p: port, mongo-gui listens on this port

Authentication in Mongo GUI

When you want to use the interface on a remote server, you need to protect your data. Mongo-gui provides you with a simple authentication facility for this. This is completely optional, if you don't want authorization you don't use it. To use authorization, follow these steps:

  • Create a .env file in the main directory.
  • In this file, create USERNAME=<your_username> variable for your username and PASSWORD="<your_password>" variable for your password.
  • Restart your server.

That's it. If you are working on your own computer, or if you do not need security, you can turn off the variables you have defined in the .env file by putting a comment before them, e.g.

  • #USERNAME=<your_username>

Or you can delete your .env file.

So mongo-gui will now continue to run without asking for authorization. Don't forget to restart your server after these actions!

Setting Up the OpenAI Prompt Query

To enable the OpenAI-powered prompt querying in Mongo GUI, you'll need to obtain an API key from OpenAI and add it to your project. Here's a step-by-step guide:

  1. Obtain an OpenAI API Key:

    • Visit OpenAI's platform
    • Sign up or log in, and navigate to the API section to generate your unique API key.
  2. Add the API Key to Your Project:

    • In the root directory of your project, look for a .env file (or create one if it doesn't exist).
    • Add the following line to the .env file:
      OPENAI_API_KEY=YOUR_API_KEY_HERE
      
      Replace YOUR_API_KEY_HERE with the API key you obtained from OpenAI.
  3. Save the .env file and restart Mongo GUI if it's currently running. With this, the AI-powered prompt querying should be activated!

🔐 Security Note: Remember to keep your .env file confidential. Never push it to public repositories or share it. It contains sensitive information.


This setup guide should provide your users with all they need to integrate the OpenAI prompt query into the tool. Adjust as needed to fit your specific application and user needs.

Screenshots

Controls:

mongo-gui-controls-v2

License

MIT

mongo-gui's People

Contributors

arunbandari avatar curioustushar avatar nmanikiran avatar parashar333 avatar patrix1337 avatar szbk avatar ugleiton avatar vidyasagar-m avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mongo-gui's Issues

Import

Supported files:

  • JSON
  • CSV

Retain property level data type while responding back to client's request

Document in DB:
{ "name": "arun", "doj": 2018-02-28T09:20:59.000Z }
here typeof doj is date

Document received by the client:
{ "name": "arun", "doj": "2018-02-28T09:20:59.000Z" }
here typeof doj is string

The following are few more types with the same behaviour

  • Date
  • ObjectId

Send the response to client in such a way that the client can restore the original document somehow.

Update collections and databases

When an collection is added, there is no way to see the change except reloading the interface, reload on databases would be useful.

Export

Selectable formats:

  • JSON
  • CSV

ENOENT: no such file or directory

Hi, I'm creating a docker-compose.yml file but when I use the compose configuration from the doc, I have this error message:

mongo-gui_1 | [Error: ENOENT: no such file or directory, stat '/app../public/index.html'] {
mongo-gui_1 | errno: -2,
mongo-gui_1 | code: 'ENOENT',
mongo-gui_1 | syscall: 'stat',
mongo-gui_1 | path: '/app../public/index.html',
mongo-gui_1 | expose: false,
mongo-gui_1 | statusCode: 404,
mongo-gui_1 | status: 404
mongo-gui_1 | }

What's going on? What can I do to fix it?

Docker image broken

[Error: ENOENT: no such file or directory, stat '/app../public/index.html'] {

errno: -2,
code: 'ENOENT',
syscall: 'stat',
path: '/app../public/index.html',
expose: false,
statusCode: 404,
status: 404

Dockerhub version does not have export to CSV

Hello, I saw in the demo that you have a button in the top right that allows you to export a collection to CSV. I installed to docker version from dockerhub using docker compose and I don't have that option.

Maybe the dockerhub image is not updated?

MongoError: can't get regex from filter doc

Hi. Great project!

I just signed up for a mongodb.com free tier account.
I installed your server and tried to connect to this DB, but nothing was working.. and it was displaying error messages.

The network tab showed that this request:

  http://localhost/databases?includeCollections=true

was returning:

  400 Bad Request
  MongoError: can't get regex from filter doc Error parsing value [{$not [{$regex {"pattern": "system.+$", "options": ""}}]}] to RegEx: Must specify $regex field

This regex pattern is used in two places:

  1. listing databases with all associated collections
  2. listing collections for a single database

In both cases, I replaced:

  .listCollections({ name: { $not: { $regex: /system.+$/ } } }).toArray()

with:

  .listCollections().toArray()

..and now the server works properly.

I don't know if this cloud service is a special case.. but I just wanted to make a PSA about this issue.
Would it be worth considering a cli option to prevent using this regex filter?
ex: mongo-gui --all-collections -p 80 -u ...

Auto ObjectID without option for string

We are not using ObjectID in our project. When I insert a doc with an _id field even if it is string, it gets automatically converted to ObjectID and there is no option to keep it string.

User Authorization Mode - Always Admins only or Flexible?

Hi @arunbandari ,

I have a user who only has read and find credentials on MongoDB for one database.

When I log on as this user - I get a warning that the user is unauthorized and inherently even that database is not displayed.

What is the default user who access the tool? Is there provision for a non-admin user?

Add url params to url to directly link to documents

Hello!
Great tool!

We used to use https://github.com/mrvautin/adminMongo and were pretty happy with it, but unfortunately it does not support replica sets and mongodb+srv:// urls.

So I found your awesome tool here.

The issue I have: we directly link to mongo documents from our own app in many places. but your tool does not have any updates in the URL/path at all. :/
I would need some way to directly link to documents in collections via their _id from the URL.

Can this be added? Thanks a lot!

Actions

Put actions to build the client and automatically send to the dockerhub

Mongo Eroor when I install the project

Hello, when I cloned the project, I tried to use it.I did my "npm install", but when i want to start the application I have the following error. Can anyone help me ?
Thanks

Capture d’écran 2021-06-28 à 09 52 58

[bug] Server.js uses CRLF instead of LF

First of all nice project!

Your server.js uses line endings CRLF instead of LF. I'm assuming you're developing on windows. It throws the following error because the shebang is corrupt:

node_modules/.bin/mongo-gui # mongo-gui is bin to ./server.js
env: node\r: No such file or directory
error Command failed with exit code 127.

You can fix this by using git config --local core.autocrlf input. This will convert all CRLF to LF when adding to the git repo.

Make URL limit customizable

If you try modifying a large JSON this will happen unless you do something like app.use(express.bodyParser({limit: '100mb'}));
If would be nice to have this as a env parameter.

{ PayloadTooLargeError: request entity too large
at readStream (/usr/local/lib/node_modules/mongo-gui/node_modules/raw-body/index.js:155:17)
at getRawBody (/usr/local/lib/node_modules/mongo-gui/node_modules/raw-body/index.js:108:12)
at read (/usr/local/lib/node_modules/mongo-gui/node_modules/body-parser/lib/read.js:77:3)
at jsonParser (/usr/local/lib/node_modules/mongo-gui/node_modules/body-parser/lib/types/json.js:135:5)
at Layer.handle [as handle_request] (/usr/local/lib/node_modules/mongo-gui/node_modules/express/lib/router/layer.js:95:5)
at trim_prefix (/usr/local/lib/node_modules/mongo-gui/node_modules/express/lib/router/index.js:317:13)
at /usr/local/lib/node_modules/mongo-gui/node_modules/express/lib/router/index.js:284:7
at Function.process_params (/usr/local/lib/node_modules/mongo-gui/node_modules/express/lib/router/index.js:335:12)
at next (/usr/local/lib/node_modules/mongo-gui/node_modules/express/lib/router/index.js:275:10)
at urlencodedParser (/usr/local/lib/node_modules/mongo-gui/node_modules/body-parser/lib/types/urlencoded.js:100:7)
message: 'request entity too large',
expected: 284167,
length: 284167,
limit: 102400,
type: 'entity.too.large' }
{ PayloadTooLargeError: request entity too large
at readStream (/usr/local/lib/node_modules/mongo-gui/node_modules/raw-body/index.js:155:17)
at getRawBody (/usr/local/lib/node_modules/mongo-gui/node_modules/raw-body/index.js:108:12)
at read (/usr/local/lib/node_modules/mongo-gui/node_modules/body-parser/lib/read.js:77:3)
at jsonParser (/usr/local/lib/node_modules/mongo-gui/node_modules/body-parser/lib/types/json.js:135:5)
at Layer.handle [as handle_request] (/usr/local/lib/node_modules/mongo-gui/node_modules/express/lib/router/layer.js:95:5)
at trim_prefix (/usr/local/lib/node_modules/mongo-gui/node_modules/express/lib/router/index.js:317:13)
at /usr/local/lib/node_modules/mongo-gui/node_modules/express/lib/router/index.js:284:7
at Function.process_params (/usr/local/lib/node_modules/mongo-gui/node_modules/express/lib/router/index.js:335:12)
at next (/usr/local/lib/node_modules/mongo-gui/node_modules/express/lib/router/index.js:275:10)
at urlencodedParser (/usr/local/lib/node_modules/mongo-gui/node_modules/body-parser/lib/types/urlencoded.js:100:7)

Copy as JSON or BSON

Screenshot 2021-03-01 at 8 51 02 AM

The copied text is in the format
{
  "_id":"5a9427648b0beebeb69579d0",
  "name":"Talisa Maegyr",
  "email":"[email protected]",
  "movie_id":"573a1390f29313caabcd41b1",
  "text":"Rem itaque ad sit rem voluptatibus. Ad fugiat maxime illum optio iure alias minus. Optio ratione suscipit corporis qui dicta.","date":"1998-08-22T11:45:03.000Z"
}

insted of

{
  "_id":
          {
             "$oid":"5a9427648b0beebeb69579d0"
          },
  "name":"Talisa Maegyr",
  "email":"[email protected]",
  "movie_id":"573a1390f29313caabcd41b1",
  "text":"Rem itaque ad sit rem voluptatibus. Ad fugiat maxime illum optio iure alias minus. Optio ratione suscipit corporis qui dicta.",
  "date":"1998-08-22T11:45:03.000Z"
}

Deploying on Server - MongoParseError

Hi Arun,

This has to be best piece of GUI for Mongo I have seen ever.

kudos for the great work - have to buy you coffee sometime soon.

So there is this section you mention in your documentation:

Installed via npm:

mongo-gui -u mongodb+srv://<username>:<password>@host/<dbnames>?retryWrites=true&w=majority

I'd like to execute this line as this:

mongo-gui -u mongodb+srv://steve:mi%23llion@localhost:27071/chickendb?retryWrites=true&w=majority

Which should open a port 4321 where I can view from my server e.g. http:32.66.74.32:4321

But I keep getting this error:

Failed to connect mongoDB - MongoParseError: URI does not have hostname, domain name and tld

Kindly tell me what I am doing wrong.

Static base href "/" in index.html interferes when exposing application with other url through Apache

Hi ,
I would like to use this application with other url I declare through Apache.
For now in order to do it I need to compile with ng build --base-href + rewrite the url in api.service.ts from:
BASE_URL = ${this.apiRoot}/databases;
to: BASE_URL = ${this.apiRoot}/my-url/databases;

Are you planning to add an environment variable in docker-compose.yaml like MONGO_URL that will replace the "/" url with a configured one?
I think it can be very helpful and many users could use your application.

Thanks!

Aggregation call

I cannot find a possibility to execute an aggregation call. Is it somewhere? If not it would be nice to have the possibility.

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.