FerretDB

module
v0.5.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 22, 2022 License: Apache-2.0

README

FerretDB

Go Reference Go Integration Docker codecov

FerretDB (previously MangoDB) was founded to become the de-facto open-source substitute to MongoDB. FerretDB is an open-source proxy, converting the MongoDB 6.0+ wire protocol queries to SQL - using PostgreSQL as a database engine.

Why do we need FerretDB?

MongoDB was originally an eye-opening technology for many of us developers, empowering us to build applications faster than using relational databases. In its early days, its ease-to-use and well-documented drivers made MongoDB one of the simplest database solutions available. However, as time passed, MongoDB abandoned its open-source roots; changing the license to SSPL - making it unusable for many open source and early-stage commercial projects.

Most MongoDB users do not require any advanced features offered by MongoDB; however, they need an easy-to-use open-source database solution. Recognizing this, FerretDB is here to fill that gap.

Scope and current state

FerretDB will be compatible with MongoDB drivers and will strive to serve as a drop-in replacement for MongoDB 6.0+.

Currently, the project is in its early stages and welcomes all contributors. See our public roadmap and contributing guidelines.

Known differences
  1. FerretDB uses the same protocol error names and codes, but the exact error messages may be different in some cases.
  2. FerretDB does not support NUL (\0) characters in strings.
  3. Database and collection names restrictions:
  • name cannot start with the reserved prefix _ferretdb_.
  • name must not include non-latin letters, spaces, dots, dollars or dashes.
  • collection name length must be less or equal than 120 symbols, database name length limit is 63 symbols.
  • name must not start with a number.
  • database name cannot contain capital letters.

If you encounter some other difference in behavior, please join our community to report a problem.

Quickstart

These steps describe a quick local setup. They are not suitable for most production use-cases because they keep all data inside containers.

  1. Store the following in the docker-compose.yml file:
version: "3"

services:
  postgres:
    image: postgres:14
    container_name: postgres
    ports:
      - 5432:5432
    environment:
      - POSTGRES_USER=user
      - POSTGRES_DB=ferretdb
      - POSTGRES_HOST_AUTH_METHOD=trust

  postgres_setup:
    image: postgres:14
    container_name: postgres_setup
    restart: on-failure
    entrypoint: ["sh", "-c", "psql -h postgres -U user -d ferretdb -c 'CREATE SCHEMA IF NOT EXISTS test'"]

  ferretdb:
    image: ghcr.io/ferretdb/ferretdb:latest
    container_name: ferretdb
    restart: on-failure
    ports:
      - 27017:27017
    command: ["-listen-addr=:27017", "-postgresql-url=postgres://user@postgres:5432/ferretdb"]

networks:
  default:
    name: ferretdb
  • postgres container runs PostgreSQL 14 that would store data.
  • postgres_setup container creates a PostgreSQL schema test that would act like a FerretDB database of the same name.
  • ferretdb runs FerretDB.
  1. Start services with docker-compose up -d.

  2. If you have mongosh installed, just run it to connect to FerretDB database test. If not, run the following command to run mongosh inside the temporary MongoDB container, attaching to the same Docker network:

docker run --rm -it --network=ferretdb --entrypoint=mongosh mongo:5 mongodb://ferretdb/

You can also install with FerretDB with the .deb and .rpm packages provided for each release.

Community

If you want to contact FerretDB Inc., please use this form.

Directories

Path Synopsis
cmd
Package ferretdb provides embeddable FerretDB implementation.
Package ferretdb provides embeddable FerretDB implementation.
integration module
internal
bson
Package bson provides converters from/to BSON for built-in and `types` types.
Package bson provides converters from/to BSON for built-in and `types` types.
clientconn
Package clientconn provides client connection implementation.
Package clientconn provides client connection implementation.
clientconn/conninfo
Package conninfo provides a ConnInfo struct that is used to handle connection-specificinfo and can be shared through context.
Package conninfo provides a ConnInfo struct that is used to handle connection-specificinfo and can be shared through context.
fjson
Package fjson provides converters from/to FJSON (JSON with some extensions) for built-in and `types` types.
Package fjson provides converters from/to FJSON (JSON with some extensions) for built-in and `types` types.
handlers
Package handlers provides an interface for all handlers.
Package handlers provides an interface for all handlers.
handlers/common
Package common provides common code for all handlers.
Package common provides common code for all handlers.
handlers/dummy
Package dummy provides a basic handler implementation.
Package dummy provides a basic handler implementation.
handlers/pg
Package pg provides PostgreSQL handler.
Package pg provides PostgreSQL handler.
handlers/pg/pgdb
Package pgdb provides PostgreSQL connection utilities.
Package pgdb provides PostgreSQL connection utilities.
handlers/proxy
Package proxy sends requests to another wire protocol compatible service.
Package proxy sends requests to another wire protocol compatible service.
handlers/registry
Package registry provides a registry of handlers.
Package registry provides a registry of handlers.
handlers/tigris
Package tigris provides Tigris handler.
Package tigris provides Tigris handler.
handlers/tigris/tigrisdb
Package tigrisdb provides Tigris connection utilities.
Package tigrisdb provides Tigris connection utilities.
tjson
Package tjson provides converters from/to JSON with JSON Schema for built-in and `types` types.
Package tjson provides converters from/to JSON with JSON Schema for built-in and `types` types.
types
Package types provides Go types matching BSON types that don't have built-in Go equivalents.
Package types provides Go types matching BSON types that don't have built-in Go equivalents.
util/lazyerrors
Package lazyerrors provides temporary error wrapping for lazy developers.
Package lazyerrors provides temporary error wrapping for lazy developers.
util/logging
Package logging provides logging helpers.
Package logging provides logging helpers.
util/must
Package must provides Do helper function.
Package must provides Do helper function.
util/testutil
Package testutil provides testing helpers.
Package testutil provides testing helpers.
wire
Package wire provides wire protocol implementation.
Package wire provides wire protocol implementation.
tools module

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL