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

Reactive dict/map between documents #9

Open
mitar opened this issue Jul 3, 2014 · 7 comments
Open

Reactive dict/map between documents #9

mitar opened this issue Jul 3, 2014 · 7 comments

Comments

@mitar
Copy link
Member

mitar commented Jul 3, 2014

It seems a common data structure one would like is the following:

{
  related: {
    <id of a document>: {
      subfield: "Subfield value"
    },
    <id of a document>: {
      ...
    }
  }
}

So a dict/map where keys are IDs and values are a subdocument with few fields of a referenced document. One can do that as a list for now, but I think having a dict/map would be beneficial for easy direct access if key (document id) is known. But current code does not yet support keeping subdocuments in sync for such structure.

@mitar
Copy link
Member Author

mitar commented Jul 3, 2014

This is useful when there is no need for an order of those related documents. If order is needed/important, then list is required.

@mitar
Copy link
Member Author

mitar commented Sep 28, 2014

In fact, I still managed to define things with whatever is currently available, so the good question is how much this is really needed. :-)

@moonrockfamily
Copy link

I'm interested in your use case for identified related documents with a subset of fields kept sync'd. Can you share your example/general case. Much appreciated.

@mitar
Copy link
Member Author

mitar commented Sep 24, 2015

I do not understand your question. This ticket is about one particular structure of data and not a general ticket for questions about PeerDB.

@moonrockfamily
Copy link

It seems I misunderstood your idea/proposal. I initially thought you were proposing an alternative/extension to the existing ReferenceField capability fieldName: @ReferenceField and was seeking to understand your use case/why it wasn't sufficient... as per README:

class Post extends Document
  # Other fields:
  #   body

  @Meta
    name: 'Post'
    fields: =>
      # We can reference other document
      author: @ReferenceField Person, ['username', 'displayName']
      # Or an array of documents
      subscribers: [@ReferenceField Person]
      reviewers: [@ReferenceField Person, ['username', 'displayName']]

@mitar
Copy link
Member Author

mitar commented Sep 25, 2015

Yes. Here is a ticket for a different structure than what is currently implemented. But I have not seen really a need for it. I prefer to use list of subdocuments anyway. Also, I do not like data schemas where keys have meaning. So ticket/idea is here, but this is it.

@mitar
Copy link
Member Author

mitar commented Oct 21, 2015

This can also work only if <id of a document> does not contain a dot (MongoDB restriction).

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

No branches or pull requests

2 participants