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

commonMain.com.ditchoom.mqtt3.persistence.SubscriptionRequestQueries.kt Maven / Gradle / Ivy

There is a newer version: 1.2.0
Show newest version
package com.ditchoom.mqtt3.persistence

import app.cash.sqldelight.Query
import app.cash.sqldelight.TransacterImpl
import app.cash.sqldelight.db.QueryResult
import app.cash.sqldelight.db.SqlCursor
import app.cash.sqldelight.db.SqlDriver
import kotlin.Any
import kotlin.Long
import kotlin.String
import kotlin.Unit

public class SubscriptionRequestQueries(
  driver: SqlDriver,
) : TransacterImpl(driver) {
  public fun  queuedSubMessages(brokerId: Long, mapper: (broker_id: Long,
      packet_id: Long) -> T): Query = QueuedSubMessagesQuery(brokerId) { cursor ->
    mapper(
      cursor.getLong(0)!!,
      cursor.getLong(1)!!
    )
  }

  public fun queuedSubMessages(brokerId: Long): Query =
      queuedSubMessages(brokerId) { broker_id, packet_id ->
    SubscribeRequest(
      broker_id,
      packet_id
    )
  }

  public fun queuedMessageCount(brokerId: Long): Query = QueuedMessageCountQuery(brokerId) {
      cursor ->
    cursor.getLong(0)!!
  }

  public fun  messageWithId(
    brokerId: Long,
    packetId: Long,
    mapper: (broker_id: Long, packet_id: Long) -> T,
  ): Query = MessageWithIdQuery(brokerId, packetId) { cursor ->
    mapper(
      cursor.getLong(0)!!,
      cursor.getLong(1)!!
    )
  }

  public fun messageWithId(brokerId: Long, packetId: Long): Query =
      messageWithId(brokerId, packetId) { broker_id, packet_id ->
    SubscribeRequest(
      broker_id,
      packet_id
    )
  }

  public fun insertSubscribeRequest(broker_id: Long, packet_id: Long): Unit {
    driver.execute(698345084, """
        |INSERT INTO SubscribeRequest (broker_id, packet_id)
        |VALUES (?, ?)
        """.trimMargin(), 2) {
          bindLong(0, broker_id)
          bindLong(1, packet_id)
        }
    notifyQueries(698345084) { emit ->
      emit("SubscribeRequest")
    }
  }

  public fun deleteSubscribeRequest(brokerId: Long, packetId: Long): Unit {
    driver.execute(-1855617682, """
        |DELETE FROM SubscribeRequest
        |WHERE broker_id = ? AND packet_id = ?
        """.trimMargin(), 2) {
          bindLong(0, brokerId)
          bindLong(1, packetId)
        }
    notifyQueries(-1855617682) { emit ->
      emit("SubscribeRequest")
    }
  }

  public fun deleteAll(brokerId: Long): Unit {
    driver.execute(597847928, """DELETE FROM SubscribeRequest WHERE broker_id = ?""", 1) {
          bindLong(0, brokerId)
        }
    notifyQueries(597847928) { emit ->
      emit("SubscribeRequest")
    }
  }

  private inner class QueuedSubMessagesQuery(
    public val brokerId: Long,
    mapper: (SqlCursor) -> T,
  ) : Query(mapper) {
    public override fun addListener(listener: Query.Listener): Unit {
      driver.addListener(listener, arrayOf("SubscribeRequest"))
    }

    public override fun removeListener(listener: Query.Listener): Unit {
      driver.removeListener(listener, arrayOf("SubscribeRequest"))
    }

    public override fun  execute(mapper: (SqlCursor) -> R): QueryResult =
        driver.executeQuery(-1822432837, """SELECT * FROM SubscribeRequest WHERE broker_id = ?""",
        mapper, 1) {
      bindLong(0, brokerId)
    }

    public override fun toString(): String = "SubscriptionRequest.sq:queuedSubMessages"
  }

  private inner class QueuedMessageCountQuery(
    public val brokerId: Long,
    mapper: (SqlCursor) -> T,
  ) : Query(mapper) {
    public override fun addListener(listener: Query.Listener): Unit {
      driver.addListener(listener, arrayOf("SubscribeRequest"))
    }

    public override fun removeListener(listener: Query.Listener): Unit {
      driver.removeListener(listener, arrayOf("SubscribeRequest"))
    }

    public override fun  execute(mapper: (SqlCursor) -> R): QueryResult =
        driver.executeQuery(1666847001,
        """SELECT COUNT(broker_id) FROM SubscribeRequest WHERE broker_id = ?""", mapper, 1) {
      bindLong(0, brokerId)
    }

    public override fun toString(): String = "SubscriptionRequest.sq:queuedMessageCount"
  }

  private inner class MessageWithIdQuery(
    public val brokerId: Long,
    public val packetId: Long,
    mapper: (SqlCursor) -> T,
  ) : Query(mapper) {
    public override fun addListener(listener: Query.Listener): Unit {
      driver.addListener(listener, arrayOf("SubscribeRequest"))
    }

    public override fun removeListener(listener: Query.Listener): Unit {
      driver.removeListener(listener, arrayOf("SubscribeRequest"))
    }

    public override fun  execute(mapper: (SqlCursor) -> R): QueryResult =
        driver.executeQuery(-1852640790,
        """SELECT * FROM SubscribeRequest WHERE broker_id = ? AND packet_id = ? LIMIT 1""", mapper,
        2) {
      bindLong(0, brokerId)
      bindLong(1, packetId)
    }

    public override fun toString(): String = "SubscriptionRequest.sq:messageWithId"
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy