DEV Community

Pacharapol Withayasakpunt
Pacharapol Withayasakpunt

Posted on

A quick glance at PostgreSQL (Node.js driver) - better than doc-type NoSQL, and too good to be true

And I like it more than not like it, that is it like NoSQL in "strict mode".

  • TEXT[] with JSONB index or GIN index is supported.
  • ARRAY, JSONB and TIMESTAMP, with automatic conversion to-and-back JavaScript Objects, Array, Object and Date.
  • Unsurprisingly, ALTER TABLE ADD COLUMN is supported.

No, I don't use standard Postgres this time

I don't know if MongoDB supports extensions, but Postgres does, and even third parties.

I am talking about non-English full text search, in Chinese and Japanese; using https://pgroonga.github.io

Dockerfile

FROM postgres:13
RUN apt-get update
RUN apt-get install -y wget

WORKDIR /app
RUN wget https://packages.groonga.org/debian/groonga-apt-source-latest-buster.deb
RUN apt-get install -y ./groonga-apt-source-latest-buster.deb
RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ buster-pgdg main" | tee /etc/apt/sources.list.d/pgdg.list
RUN wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -
RUN apt-get update
RUN apt-get install -y postgresql-13-pgdg-pgroonga
RUN apt-get install -y groonga-tokenizer-mecab
Enter fullscreen mode Exit fullscreen mode

docker-compose.yml

version: "3"
services:
  db:
    build: ./packages/db
    environment:
      - POSTGRES_USER=postgres
      - POSTGRES_PASSWORD=postgress
      - POSTGRES_DB=postgres
    ports:
      - "5433:5432"
    volumes:
      - pgdata:/var/lib/postgresql/data
volumes: 
  pgdata:
Enter fullscreen mode Exit fullscreen mode

So, what did I really install on my machine?

I did install Postgres on my machine to test it first; but I don't think it is really needed.

More importantly,

  • pgAdmin

I still want better full-text search.

What about

  • Column specific search, if wanted
  • Non-text search query string

I am positive I can create my own query language, as I have done it before; but what matters more here is performance... as I am privileged
enough to have today.

And, yeah, MongoDB does have full-text index; but it is very primitive to me.

Billboard image

Deploy and scale your apps on AWS and GCP with a world class developer experience

Coherence makes it easy to set up and maintain cloud infrastructure. Harness the extensibility, compliance and cost efficiency of the cloud.

Learn more

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay