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

ldbc.query.builder.syntax.CommandSyntax.scala Maven / Gradle / Ivy

The newest version!
/**
 * Copyright (c) 2023-2024 by Takahiko Tominaga
 * This software is licensed under the MIT License (MIT).
 * For more information see LICENSE or https://opensource.org/licenses/MIT
 */

package ldbc.query.builder.syntax

import ldbc.dsl.*
import ldbc.dsl.codec.Decoder
import ldbc.query.builder.statement.Command

trait CommandSyntax[F[_]]:

  extension (command: Command)

    /**
     * A method to execute an update operation against the MySQL server.
     *
     * {{{
     *   Table[User]
     *     .update("id", 1L)
     *     .set("name", "Alice")
     *     .set("age", 20)
     *     .where(_.id === 1L)
     *     .update
     * }}}
     *
     * @return
     *   The number of rows updated
     */
    def update: Executor[F, Int]

    /**
     * A method to execute an insert operation against the MySQL server.
     *
     * {{{
     *   Table[User]
     *     .insertInto(user => (user.name, user.age))
     *     .values(("Alice", 20))
     *     .returning[Long]
     * }}}
     *
     * @tparam T
     *   The type of the primary key
     * @return
     *   The primary key value
     */
    def returning[T <: String | Int | Long](using decoder: Decoder.Elem[T]): Executor[F, T]




© 2015 - 2024 Weber Informatics LLC | Privacy Policy