Skip to content

Default values or hooks for relationship properties? #86

@exoup

Description

@exoup

I have a User model with a relationships property that looks like this:

Surveys: {
            model: Survey,
            direction: 'out',
            name: 'IS_PARTICIPANT',
            properties: {
                Feedback: {
                    property: 'feedback',
                    schema: {
                        type: 'string'
                    }
                },
                Complete: {
                    property: 'complete',
                    schema: {
                        type: 'boolean'
                    }
                }
            }
        }

Is there a way to give these a default value or a beforeCreate hook?
When I go to create a user node and associate it with a Survey node, I get a Neo4j error about missing feedback and complete parameters.

I've tried adding a default value but it does not work.

I was creating my user node like this:

    const user = User.createOne({
        name: 'John Doe',
        email: 'john.doe@acme.co',
        department: 'Engineering',
        title: 'Software Engineer',
    });
    await user.relateTo({
        alias: 'Surveys',
        where: {
            target: {
                code: "ABC123"
            }
        }
    })

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions