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

commonMain.com.ditchoom.mqtt3.persistence.UnsubscribeRequestQueries.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 UnsubscribeRequestQueries(
  driver: SqlDriver,
) : TransacterImpl(driver) {
  public fun  queuedUnsubMessages(brokerId: Long, mapper: (broker_id: Long,
      packet_id: Long) -> T): Query = QueuedUnsubMessagesQuery(brokerId) { cursor ->
    mapper(
      cursor.getLong(0)!!,
      cursor.getLong(1)!!
    )
  }

  public fun queuedUnsubMessages(brokerId: Long): Query =
      queuedUnsubMessages(brokerId) { broker_id, packet_id ->
    UnsubscribeRequest(
      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 ->
    UnsubscribeRequest(
      broker_id,
      packet_id
    )
  }

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

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

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

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

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

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

    public override fun toString(): String = "UnsubscribeRequest.sq:queuedUnsubMessages"
  }

  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("UnsubscribeRequest"))
    }

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

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

    public override fun toString(): String = "UnsubscribeRequest.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("UnsubscribeRequest"))
    }

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

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

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




© 2015 - 2025 Weber Informatics LLC | Privacy Policy