• Stars
    star
    258
  • Rank 158,189 (Top 4 %)
  • Language
    Rust
  • License
    Apache License 2.0
  • Created over 2 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Teach your PostgreSQL database how to speak MongoDB Wire Protocol

banner-small

โ€œIf it looks like MongoDB, swims like MongoDB, and quacks like MongoDB, then it probably is PostgreSQL.โ€ ๐Ÿ™ƒ

Discord | Online Demo | Intro Video | Quickstart

OxideDB

OxideDB is a translation layer that works as a MongoDB database server while using PostgreSQL's JSON capabilities as the underlying data store.

Audience

This project might be something that you could be interested on if:

  • You spend too much time managing; or too much money paying for a MongoDB instance, while only using it as a simple document store, without any sharding features
  • You already have a running PostgreSQL deployment, or prefer to manage it over MongoDB

On the other hand, if your use-case leverages MongoDB as a distributed database, then unfortunately this project might not be for you. At least right now supporting multi-sharding and scale-out deployments is not part of the roadmap.

Current status

The project was heavily inspired by FerretDB and is on its early days. The main difference is that there is no intention to support any database other than PostgreSQL (FerretDB is also supporting Tigris) and it's written in Rust, as opposed to Go.

In order to translate the MongoDB Query language - which is based on JSON - to SQL I have ported the mongodb-language-model library that was originally written in Node.js and PEG.js to Rust and pest.rs. It was an excellent opportunity to learn how parsers work in a bit more depth.

You can check it out here: mongodb-language-model-rust.

At this moment, it's being developed as a personal project, but contributors are highly welcomed. If that something you'd be interested on, be more than welcome to contact me.

Online demo

There's an online demo of the Web Interface live hosted at Railway.app.

Quickstart

Download the latest binary and run it. You will need to point it to a running PostgreSQL for Oxide to use as its backend.

> $ ./oxide --postgres-url "postgres://postgres:postgres@localhost:5432/test"
[2022-07-13T02:57:46Z INFO  oxide::server] Connecting to postgres://*****:*****@localhost:5432/test...
[2022-07-13T02:57:46Z INFO  oxide::server] OxideDB listening on 127.0.0.1:27017...

And with the database configuration set, you can use any MongoDB client to connect to OxideDB, like mongosh:

> $ mongosh
Current Mongosh Log ID:	62ce3531d10f489bc82520c4
Connecting to:		mongodb://127.0.0.1:27017/?directConnection=true&serverSelectionTimeoutMS=2000&appName=mongosh+1.5.0
Using MongoDB:		3.6.23
Using Mongosh:		1.5.0

For mongosh info see: https://docs.mongodb.com/mongodb-shell/

------
   The server generated these startup warnings when booting
   2022-07-12T18:56:41.654-0300:
   2022-07-12T18:56:41.654-0300: ** WARNING: Access control is not enabled for the database.
   2022-07-12T18:56:41.654-0300: **          Read and write access to data and configuration is unrestricted.
   2022-07-12T18:56:41.654-0300:
------

test> db.col.insertMany([{ name: "Felipe" }, { name: "Fernanda" }]);
{
  acknowledged: true,
  insertedIds: {
    '0': ObjectId("62ce3536d10f489bc82520c5"),
    '1': ObjectId("62ce3536d10f489bc82520c6")
  }
}
test> db.col.find({ "name": "Fernanda" })
[ { _id: ObjectId("62ce3536d10f489bc82520c6"), name: 'Fernanda' } ]

Quick intro

Intro to OxideDB

Web interface

Web UI

If you want to perform quick queries on your database, you can use the built in web interface, just start oxide with the --web flag:

> $ ./oxide --postgres-url postgres://postgres:postgres@localhost:5432/oxide
[2022-07-29T00:20:11Z INFO  oxide::server] Connecting to postgres://*****:*****@localhost:5432/oxide...
[2022-07-29T00:20:11Z INFO  oxide::server] OxideDB listening on 0.0.0.0:27017...

Now just navigate to http://localhost:5432 and you'll be able to perform quick queries.

Running options

You can also set the DATABASE_URL environment variable or even use a .env file.

By default oxide will bind to 127.0.0.1 and port 27017. You can change those settings using the following parameters:

> $ ./oxide --help
oxide 0.1.6
A database compatible with MongoDB Wire Protocol that uses PostgreSQL for backend storage.

USAGE:
    oxide [OPTIONS]
    oxide <SUBCOMMAND>

OPTIONS:
    -d, --debug                          Show debugging information
    -h, --help                           Print help information
    -l, --listen-addr <LISTEN_ADDR>      Listening address, defaults to 127.0.0.1
    -p, --port <PORT>                    Listening port, defaults to 27017
    -u, --postgres-url <POSTGRES_URL>    PostgreSQL connection URL
    -V, --version                        Print version information
    -w, --web                            Starts web interface
        --web-addr <WEB_ADDR>            Web binding address

SUBCOMMANDS:
    help    Print this message or the help of the given subcommand(s)
    web     Start OxideDB web interface

Running with Docker

Assuming you're running a local PostgreSQL instance, you can run OxideDB with Docker with the command below.

docker build -t oxide .
docker run -d -p 27017:27017 -p 8087:8087 -e DATABASE_URL=postgres://postgres:[email protected]:5432/test --name oxide oxide

Running from source

git clone https://github.com/fcoury/oxide.git
cd oxide
export DATABASE_URL="postgres://postgres:postgres@localhost:5432/test"
make start

More Repositories

1

octopi

A Ruby interface to GitHub API v2
Ruby
216
star
2

kbpcb

Automated Keyboard PCB generator for KiCad
HTML
72
star
3

atom-rspec

Atom RSpec runner package
CoffeeScript
69
star
4

jfilehelpers

JFileHelpers is a library that automates the tedious task of parsing and creating structured text files. It handles fixed width or delimited files with Java annotations sweetness.
Java
46
star
5

node-anne-pro

Bluetooth communication library for the Anne Pro keyboard
JavaScript
27
star
6

intweet

Twitter. Keywords. Alerts.
Ruby
18
star
7

gitorious

Gitorious
Ruby
11
star
8

electron-anne-pro

Electron based Anne Pro Keyboard configurator
JavaScript
10
star
9

angular2-reddit

JavaScript
7
star
10

mongodb-language-model-rust

PEG.js
5
star
11

qmk_firmware_anne_pro

C
3
star
12

runst

JavaScript
3
star
13

mrkeebs

JavaScript
3
star
14

api-labrat

Lab rat for GitHub API interaction using Octopi
3
star
15

dotzsh

Shell
2
star
16

vscode-pretty-sql

TypeScript
2
star
17

qmk_configurator_react

CSS
2
star
18

servant

My MacRuby experience with server list selector
2
star
19

phd

Passenger-based Heroku-like Deployment
Ruby
2
star
20

rails-sti-caching

Isolated test for Rails Single-Table Inheritance caching problem
Ruby
2
star
21

ps2msx

Arduino + USB Host shield adapter from USB to MSX PS/2
C++
2
star
22

labelbug

A project to isolate the possible bug with rendering for attribute for label_tag as opposed to radio_button_tag
Ruby
2
star
23

via-layouts

2
star
24

mechpad

JavaScript
2
star
25

elongate

1
star
26

esp8266_mcp23017_oled96x64_rotary

C++
1
star
27

chicory40

1
star
28

scripts

AppleScript
1
star
29

jsmine

JavaScript
1
star
30

cookbooks

Chef cookbooks
Ruby
1
star
31

ajaxenterm

Python
1
star
32

ghostplus

Improved version of ghost
Ruby
1
star
33

ce_ele

Ruby
1
star
34

sample-rust-store

Rust
1
star
35

hirb-isolated

Isolated test for HIRB problem
Ruby
1
star
36

bling

bling bling gem management
Ruby
1
star
37

razermon

Add a Razer device battery monitoring gadget to your macOS menubar.
Rust
1
star
38

cursoprevestibular

Sistema para controle de cursinho prรฉ vestibular
1
star
39

wasmsx

TypeScript
1
star
40

espera

JavaScript
1
star
41

fcoury.github.com

Ruby
1
star
42

emulator-bus-minimal

Rust
1
star