Restream / reindexer

Embeddable, in-memory, document-oriented database with a high-level Query builder interface.
https://reindexer.io
Apache License 2.0
763 stars 64 forks source link

"Index is not appendable" error for nested structure #51

Closed difengo closed 4 years ago

difengo commented 4 years ago

Hi,

I'm trying to use several instances of a nested structure within another one and I'm receiving an "Index # is not appendable" error.

My structures are the following:

// EntityReference represents a reference link to an entity.
type EntityReference struct {
    // The unique id of the referenced entity.
    ID string `json:"#" reindex:"#"`
        // The typename of the referenced entity.
        TypeName string `json:"typeName" reindex:"typeName"`
}

// Employee is the type used to represent an employee.
type Employee struct {
    // The id of the underlying or referenced entity in the database.
    ID string `json:"_key" reindex:"_key,hash,pk"`
    // The date/time the record was created (YYYY-MM-DDThh:mm:ssZ).
    CreatedAt *string `json:"createdAt,omitempty" reindex:"createdAt"`
    // The date/time the record was last updated (YYYY-MM-DDThh:mm:ssZ).
    UpdatedAt *string `json:"updatedAt,omitempty" reindex:"updatedAt"`
    // Defines if the entity is active.
    Active bool `json:"active" reindex:"active"`
    // The reference to the associated user (User).
    User *EntityReference `json:"user,omitempty" reindex:"user"`
    // The reference to the associated profile (Profile).
    Profile *EntityReference `json:"profile,omitempty" reindex:"profile"`
    // The reference to the associated organization (Organization).
    Organization *EntityReference `json:"organization,omitempty" reindex:"organization"`
    // The reference to the associated business unit (Unit).
    Unit *EntityReference `json:"unit,omitempty" reindex:"unit"`
    // The reference to the associated company site (Site).
    Site *EntityReference `json:"site,omitempty" reindex:"site"`
    // The reference to the associated current job (Job).
    Job *EntityReference `json:"job,omitempty" reindex:"job"`
} 

I'm certainly doing something wrong, so how do I do that ?

difengo commented 4 years ago

Found myself that tags must not be added to nested struct fields ;-)