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

Add metadata #7

Closed
TimoBechtel opened this issue Jan 12, 2021 · 2 comments
Closed

Add metadata #7

TimoBechtel opened this issue Jan 12, 2021 · 2 comments
Assignees
Labels
enhancement New feature or request released on @next
Milestone

Comments

@TimoBechtel
Copy link
Owner

TimoBechtel commented Jan 12, 2021

What

Implement a way to add metadata to nodes.

So instead of having a child node directly under each node, e.g.

{
  my: {
     pathTo: {
       some: "value"
     }
   }
}

we'd have an object representing each node:

{
  my: {
    meta: {
      created: "created timestamp",
      owner: "some user id"
    },
    value: {
      pathTo: {
        meta: {},
        value: {
          some: {
            meta: {},
            value: "value"
          }
        }
      }
    }
  }
}

Or as an array maybe?

{
  my: [
    {
      created: "created timestamp",
      owner: "some user id"
    },
    {
      pathTo: []
    }
  ]
}

Why

Currently there is no way to add metadata. To add plugin support, we need some way to add metadata.

This would allow us to add a hole range of new features, like adding a timestamp, a permission / ownership system and more.

@TimoBechtel TimoBechtel self-assigned this Jan 12, 2021
@TimoBechtel TimoBechtel added the enhancement New feature or request label Jan 12, 2021
@TimoBechtel
Copy link
Owner Author

TimoBechtel commented Jan 15, 2021

Ok, so there are two ideas of adding/manipulating metadata, which is going to be synchronized between clients:

1. using set:

db.get('path').set('mydata', {type: 'array'});

db.get('path').set('myotherdata', permissions({user: "rw"});

With this approach, it's a little awkward, when you want to set metadata without actually changing data, because then you need to "set" an empty object:

db.get('path').set({}, permissions({user: "r"});

2. adding a method with:

db.get('path').with(permissions({user: "r"}).set('mydata');

And if you only want to change metadata without changing the actual data:

db.get('path').with(permissions({user: "r"}).set();

However, with can also be used in combination with plugins to set a specific context.
'plugin context' and 'meta data' should be considered separat, as the plugin context is only used locally by plugins and the meta data is synchronized across clients. See #8


EDIT: moved 2. with modifier function to separate issue: #15

TimoBechtel added a commit that referenced this issue Jan 27, 2021
TimoBechtel added a commit that referenced this issue Jan 27, 2021
@TimoBechtel TimoBechtel added this to the v3 milestone Jan 30, 2021
TimoBechtel added a commit that referenced this issue Feb 12, 2021
allow setting metadata by providing a second argument to "set"

closes #7
github-actions bot pushed a commit that referenced this issue Feb 12, 2021
# [3.2.0](v3.1.0...v3.2.0) (2021-02-12)

### Features

* **client:** allow setting metadata ([f35131b](f35131b)), closes [#7](#7)
@github-actions
Copy link
Contributor

🎉 This issue has been resolved in version 3.2.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

No branches or pull requests

1 participant