toluaina / pgsync

Postgres to Elasticsearch/OpenSearch sync
https://pgsync.com
MIT License
1.19k stars 182 forks source link

Adjacency list #296

Open Lelouch1 opened 2 years ago

Lelouch1 commented 2 years ago

Hello, tell me please does it support adjacency list in schema definition? It looks like in same table, we have parent id, which refers to an id in the same table.

i try'd like this, but something went wrong...

[
  {
    "database": "test-db",
    "index": "test-index",
    "nodes": {
      "table": "table_for_example",
      "schema": "public",
      "columns": [],
      "children" : [
        {
          "table": "table_for_example",
          "relationship": {
            "variant": "object",
            "type": "one_to_many",
            "foreign_key": {
              "child": ["id"],
              "parent": ["parent_id"]
            }
          }
        }
      ]
    }
  }
]
Wild-Soul commented 2 years ago

Hi @Lelouch1 , I think this comment might help you.

toluaina commented 2 years ago

This is not supported yet. It was also requested here. I am still working on this

Lelouch1 commented 2 years ago

@toluaina Thank you, I'll be waiting

Lelouch1 commented 2 years ago

@toluaina hi, saw the new release, do you solved the problem? thx:)

toluaina commented 2 years ago
skantrus commented 2 years ago

Hi! Discover same error when try to add children from same table. Want to make flat architecture from inheritance with adjacency list schema

{
    "label": "children",
    "table": "same_table",
    "columns": [
        "id",
        "detail"
    ],
    "relationship": {
        "type": "one_to_many",
        "variant": "object",
        "foreign_key": {
            "child": [
                "parent_id"
            ],
            "parent": [
                "id"
            ]
        }
    }
}

@toluaina May bee I can help you, if you look at this code fix example: image But still it wont track update parent if new child was added