Skip to content
This repository was archived by the owner on Jul 14, 2024. It is now read-only.

Repositories

FabienCAYRE edited this page Mar 4, 2023 · 2 revisions

The Flow repository system is similar to the Spring repository system. For now, Flow has three different repository type: MongoDB, Redis and InMemory.

The way you create a repository for your datas is as follow:

public User{
  @Id
  private UUID id;
}

@Repository
public interface UserRepository extends {X}Repository<User, UUID>{

}

{X} is the type of your data backend, like Mongo, Redis or Java if it's in Memory.

You can either choose to extends fr.omny.flow.api.data.MongoRepository, fr.omny.flow.api.data.RedisRepository, fr.omny.flow.api.data.JavaRepository (for in memory data). For now, Flow doesn't support custom Repository, but I'm working on it.

Depending on the type of Repository, you need to add specific annotations.

Redis

@REntity
public User{
  @Id
  @RId
  private UUID id;
}

@Repository
public interface UserRepository extends RedisRepository<User, UUID>{

}

@REntity and @RId are Redisson annotation for RedisLiveObject, which is the backend of RedisRepository for now.

Mongo

public User{
  @Id
  @BsonId
  private UUID id;
  @BsonProperty
  private String props;
}

@Repository
public interface UserRepository extends MongoRepository<User, UUID>{
}

Clone this wiki locally