grahamjenson / hapiger

HapiGer is an http-wrapper around the Good Enough Recommendation engine using the Hapi.js framework
174 stars 36 forks source link

PG Database is not being used? #18

Closed rogiervandenberg closed 6 years ago

rogiervandenberg commented 6 years ago

Hi, I just installed HapiGER, but it won't work, but there is also no error.

My setup

Installed HapiGER:

npm install -g hapiger

Created a database in my Postgres (hapiger) and start HapiGER as explained in your documentation:

hapiger --es pg --esoptions '{
    "connection":"postgres://localhost/hapiger"
  }'

It seems to be connecting, my database gets connected to and without having the database HapiGER will not start due to an error ("Knex:Error Pool2 - error: database "xxx" does not exist")

My issue

But now, when creating a namespace, e.g:

curl -X POST 'http://localhost:3456/namespaces' -d'{
    "namespace": "movies"
  }'

--> Returns {"namespace":"movies"}%

and and event:

curl -X POST 'http://localhost:3456/events' -d '{
    "events": [
    {
      "namespace": "movies",
      "person":    "Alice",
      "action":    "view",
      "thing":     "Harry Potter"
    }
  ]
}'

--> Returns {"events":[{"person":"Alice","action":"view","thing":"Harry Potter","created_at":"2018-01-19T12:08:53.873Z"}]}%

...nothing is stored in the database. Or retrievable at all..

Any clues, or what to look out for?

grahamjenson commented 6 years ago

Where are you looking in the database? Because when you create a namespace it creates a postgres schema. So a select * wont work without specifying the schema.

So you can list all schema with

select nspname
from pg_catalog.pg_namespace;

from here

Or try \dt *.* which will list all tables in all schemas, from here

rogiervandenberg commented 6 years ago

Well, I was looking for the place where stuff was stored, but never used the concept of namespaces, or was aware of them.

What I get now is that per type of thing a namespace is created :)

With a simple select * from movies.events; I found was I was looking for. So thank you, I'll be continuing playing with this amazing project 👍