💡MongoDbModel

Every database model must implment MongoDbModel.

A class must have a field that is annotated by Id annotation

Define your table name in geTableName method.

The table name must be defined without a table prefix.

Example of the implementation of MongoDbModel.


public class MyUser implements MongoDbModel, User {

    @Id
    private final UUID uuid;
    private double coins;
    
    public static final String COLLECTION_NAME = "users";

    public MyUser(UUID uuid, double coins) {
        this.uuid = uuid;
        this.coins = coins;
    }
    
    //getters and setters
    
    @Override
    public String getCollectionName() {
        return COLLECTION_NAME;
    }
    
    @Override //you can create your own DAO (optional)
    public Dao getDao() {
        return new MongoDbMyUserDao(this);
    }
}

Last updated