All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.lightningkite.ktordb.FieldCollection.kt Maven / Gradle / Ivy

The newest version!
package com.lightningkite.ktordb

import kotlinx.coroutines.flow.Flow
import kotlin.reflect.KProperty1

interface FieldCollection {
    val wraps: FieldCollection? get() = null
    suspend fun fullCondition(condition: Condition): Condition = condition
    suspend fun mask(model: Model): Model = model

    suspend fun find(
        condition: Condition,
        orderBy: List> = listOf(),
        skip: Int = 0,
        limit: Int = Int.MAX_VALUE,
        maxQueryMs: Long = 15_000
    ): Flow

    suspend fun count(
        condition: Condition = Condition.Always()
    ): Int

    suspend fun  groupCount(
        condition: Condition = Condition.Always(),
        groupBy: KProperty1
    ): Map

    suspend fun  aggregate(
        aggregate: Aggregate,
        condition: Condition = Condition.Always(),
        property: KProperty1
    ): Double?

    suspend fun  groupAggregate(
        aggregate: Aggregate,
        condition: Condition = Condition.Always(),
        groupBy: KProperty1,
        property: KProperty1
    ): Map


    suspend fun insert(
        models: List
    ): List


    suspend fun replaceOne(
        condition: Condition,
        model: Model
    ): EntryChange

    /**
     * @return If a change was made to the database.
     */
    suspend fun replaceOneIgnoringResult(
        condition: Condition,
        model: Model
    ): Boolean

    suspend fun upsertOne(
        condition: Condition,
        modification: Modification,
        model: Model
    ): EntryChange

    /**
     * @return If there was an existing element that matched the condition.
     */
    suspend fun upsertOneIgnoringResult(
        condition: Condition,
        modification: Modification,
        model: Model
    ): Boolean


    suspend fun updateOne(
        condition: Condition,
        modification: Modification,
    ): EntryChange

    /**
     * @return If a change was made to the database.
     */
    suspend fun updateOneIgnoringResult(
        condition: Condition,
        modification: Modification
    ): Boolean


    suspend fun updateMany(
        condition: Condition,
        modification: Modification,
    ): CollectionChanges

    /**
     * @return The number of entries affected.
     */
    suspend fun updateManyIgnoringResult(
        condition: Condition,
        modification: Modification,
    ): Int


    suspend fun deleteOne(
        condition: Condition
    ): Model?

    /**
     * @return Whether any items were deleted.
     */
    suspend fun deleteOneIgnoringOld(
        condition: Condition
    ): Boolean


    suspend fun deleteMany(
        condition: Condition
    ): List

    /**
     * @return The number of entries affected.
     */
    suspend fun deleteManyIgnoringOld(
        condition: Condition
    ): Int

    suspend fun watch(
        condition: Condition
    ): Flow>
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy