Skip to content

Embedded documents with reference #308

@joshystuart

Description

@joshystuart

Hi there,

Firstly, thanks for the great software.

Secondly, this is a question more than an issue. I have the following data model:

Event

{
    data: {
        casualties: {
            death: {
                number: Number,
                cause: String
            },
            injury: {
                number: Number,
                cause: String
            }
        },
        punishment: {
            number: Number,
            penalty: String
        }
    }
}

Causality

{
    name: {type: String, index: true},
    createdBy: {type: [String]},
    updatedBy: {type: [String]}
}

Punishment

{
    name: {type: String, index: true},
    createdBy: {type: [String]},
    updatedBy: {type: [String]}
}

I want to create a field in an edit view that has:

Death | field: number of deaths | reference to causality entity as a dropdown: cause
Injury | field: number of injuries | reference to causality entity as a dropdown: cause
Punishment | field: number of punishments | reference to penalties entity as a dropdown: penalty

I tried to create the following:

In config.js

...
.addField(new Reference('data')
      .type('template')
      .targetEntity(new Entity('casualties.casualties'))
      .targetField(new Field('name'))
      .template(function () {
        return '<dataedit field="::field"></dataedit>';
      }))
...

However, when I tired to get the field.choices() in the data-edit directive, it returns an empty list, but it should contain entries.

I'm not sure if I'm going about this in the right way.

Any help would be greatly appreciated!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions