Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Node References and Nested Inserts #11

Open
amaster507 opened this issue Sep 16, 2022 · 1 comment
Open

Feature Request: Node References and Nested Inserts #11

amaster507 opened this issue Sep 16, 2022 · 1 comment
Labels
enhancement New feature or request

Comments

@amaster507
Copy link
Contributor

What you wanted to do

Nested inserts of nodes. Insert items into a collection and in a nested manner, insert items into the same or different collections.

What you did instead

I could insert vectors and maps, but these vectors and maps would all be part of the same item in the parent collection and could not be queried from other collections.

collection|person|:q[
  insert[
    person|foo|:m{
      s|name|:s|Foo|
    }
  ],
  insert[
    m{
      s|name|:s|Bar|,
      s|friends|:v[
        person|foo|
      ]
    }
  ]
]

The work around to this is to do back to back inserts into collections and handle the linking in subsequent queries insert operations.

Ideas on what this might look like

What if inserts could be cascaded. Right now it seems nothing can come in the pipe after an insert. But what if you could do something like this for starters:

collection|person|:q[
  insert[
    person|foo|:m{
      s|name|:s|Foo|
    }
  ],
  insert[
    m{
      s|name|:s|Bar|,
      s|friends|:v[
        person|foo|
      ]
    }
  ]
]

The person|foo| is a temporary id that is not persisted. It is used for cross reference in the same transaction.
And then if you could do that then you could also probably do something like:

collection|person|:insert[
  m{
    s|name|:s|Bar|,
    s|friends|:v[
      person|:m{
        s|name|:s|Foo|
      }
    ]
  }
]

And combine these two to be able to create inverse relationships (see issue __):

collection|person|:insert[
  person|bar|:m{
    s|name|:s|Foo|,
    s|friends|:v[
      person|foo|:m{
        s|name|:s|Foo|,
        s|friends|:v[
          person|bar|
        ]
      }
    ]
  }
]

The person|foo| in this query is not being referenced anywhere else so in theory, this could be person| and work the same way.

And this would also allow to insert more than one collection at a time. This is where it might get complicated not knowing how the resolvers for insert work.

collection|post|:insert[
  post|p1|:m{
    s|title|:s|Check Out AnnaDB!|,
    s|comments|:v[
      comment|c1|:m{
        s|text|:s|This is pretty awesome!|,
        s|onPost|:post|p1|
        replies:v[
          comment|:m{
            s|text|:s|For sure!|,
            s|replyTo|:comment|c1|
          }
        ]
      }
    ]
  }
]
@roman-right roman-right added the enhancement New feature or request label Sep 20, 2022
@amaster507
Copy link
Contributor Author

This might depend or correlate also with: #14 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants