Skip to content

Spring Data ArangoDB : Save parent and child together #189

Closed
@naveen-kinnal

Description

@naveen-kinnal

I am trying to build my Java Spring Boot interpretation of saving ArangoDB nodes. My code looks like below Asset.java

@Data
@Document("assets")
public class Asset {

    @Id
    String key;
    String name;
    String description;
    String path;
    LocalDateTime imported_at;
}

and AssetContent.java as

@Data
@Document("asset_contents")
public class AssetContent {

    @Id
    String key;
    String name;
    String extension;
    String content;
}

ChildOf.java to give a relation between Asset and AssetContent

@Data
@Edge("edges")
public class ChildOf<T1, T2> {

    @Id
    private String id;

    @From
    private T1 child;

    @To
    private T2 parent;

    public ChildOf(final T1 child, final T2 parent) {
        super();
        this.child = child;
        this.parent = parent;
    }
}

where One Asset has multiple AssetContents. Now I want to achieve 3 things

  1. Save an Asset and list of Asset Contents at once (Create a list of AssetContents and store in my Asset.java, then save Asset should also save AssetContents).
  2. Get the asset using the AssetContent repository.
  3. Get the list of asset contents using the AssetRepository.

Since I am new to ArangoDB and also because of the limited tutorial. Could someone help me with the changes I have to make in the code?

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