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

Check what happens when a new item is added to array. Is then a new instance created? #208

Closed
mStirner opened this issue Oct 20, 2022 · 2 comments

Comments

@mStirner
Copy link
Member

E.g: Interfaces are stored in arrays under the device component. What happens when a new dataset is added to the interfaces array and the component update method is called. Is then a new interface instance created for the dataset?

I think not, how to handle that situation in the HTTP Routes?
Could be a smaller problem than expected.
For Interfaces a WebSocket server is created, if nothing is found with the _id.
Other arrays (from other componets) should not have custom "array"/item handling.

@mStirner mStirner added this to the v2.0.0 release milestone Oct 29, 2022
@mStirner
Copy link
Member Author

Adding a new Object to arrays, does not automatically create a new class instance:

updated vault Vault {
  _id: '637a5b73f4be65f505a598f7',
  name: 'Test credentials',
  identifier: 'TEST',
  secrets: [
    Secret {
      name: 'Username',
      key: 'USERNAME',
      value: [Getter/Setter],
      _id: '637a5b7df4be65f505a598f9',
      description: null
    },
    {
      name: 'Password',
      key: 'PASSWORD',
      value: 'Pa$$w0rd',
      _id: '637a5b7df4be65f505a598fa',
      description: null
    }
  ],
  timestamps: { created: 1668963187564, updated: 1668963197229 }
} [
  Secret {
    name: 'Username',
    key: 'USERNAME',
    value: [Getter/Setter],
    _id: '637a5b7df4be65f505a598f9',
    description: null
  },
  {
    name: 'Password',
    key: 'PASSWORD',
    value: 'Pa$$w0rd',
    _id: '637a5b7df4be65f505a598fa',
    description: null
  }
]
        C_VAULT.add({
            name: "Test credentials",
            identifier: "TEST",
            secrets: [{
                name: "Username",
                key: "USERNAME",
                value: "marc.stirner@example.com"
            }]
        }, (err, item) => {

            console.log("Vault:", err || item);


        });

        C_VAULT.events.on("update", (item) => {
            console.log("Updated vault", item, item.secrets);
        });

Updated via HTTP API. (http://{{HOST}}:{{PORT}}/api/vault/637a5b73f4be65f505a598f7)

mStirner added a commit to mStirner/backend that referenced this issue Nov 21, 2022
@mStirner
Copy link
Member Author

See 202efca.
As thought, nothing happens when a new item is added to a array which contains objects that represents class instances.

How should this be handled?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant