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

io.funkode.arangodb.model.Query.scala Maven / Gradle / Ivy

There is a newer version: 0.3.6
Show newest version
/*
 * Copyright 2022 Carlos Verdes
 *
 * SPDX-License-Identifier: MIT
 */

package io.funkode.arangodb.model

import io.funkode.velocypack.*

case class Query(
    query: String,
    bindVars: Option[VPack.VObject],
    batchSize: Option[Long] = None,
    cache: Option[Boolean] = None,
    count: Option[Boolean] = None,
    memoryLimit: Option[Long] = None,
    options: Option[Query.Options] = None,
    ttl: Option[Long] = None
)

object Query:

  def apply(query: String): Query = new Query(query, None)
  def apply(query: String, bindVars: VPack.VObject): Query = new Query(query, Some(bindVars))

  extension (q: Query)
    def bindVar(key: String, value: VPack): Query =

      import VPack.*
      import VObject.updated

      val newBindVars: VPack.VObject =
        q.bindVars.map(_.updated(key, value)).getOrElse(VObject(Map(key -> value)))
      q.copy(bindVars = Some(newBindVars))

  final case class Options(
      failOnWarning: Option[Boolean],
      fullCount: Option[Boolean],
      intermediateCommitCount: Option[Long],
      intermediateCommitSize: Option[Long],
      maxPlans: Option[Long],
      maxTransactionSize: Option[Long],
      maxWarningCount: Option[Long],
      optimizerRules: Option[List[String]],
      profile: Option[Int],
      satelliteSyncWait: Option[Boolean],
      skipInaccessibleCollections: Option[Boolean],
      stream: Option[Boolean]
  )




© 2015 - 2025 Weber Informatics LLC | Privacy Policy