@rvoh/dream
    Preparing search index...

    Class KyselyQueryDriver<DreamInstance>

    Type Parameters

    • DreamInstance extends Dream

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    connectionOverride: DbConnectionType | undefined
    dreamClass: DreamConstructorType<DreamInstance>
    dreamInstance: DreamInstance
    dreamTransaction: DreamTransaction<Dream, any> | null = null
    innerJoinDreamClasses: readonly typeof Dream[] = ...

    stores the Dream models joined in this Query instance

    query: Query<DreamInstance, any>

    Accessors

    Methods

    • Retrieves the average value of the specified column for this Query

      await Game.query().avg('score')
      // 1

      Parameters

      • columnName: string

        a column name on the model

      Returns Promise<any>

      the average of the values of the specified column for this Query

    • Internal

      This method is used internally by a Query driver to take the result of a single row in a database, and turn that row into the provided dream instance.

      If needed, the return type can be overriden to explicitly define the resulting dream instance, in cases where a proper type for the dream class cannot be inferred, i.e.

      this.dbResultToDreamInstance<typeof Dream, DreamInstance>(result, this.dreamClass)
      

      Type Parameters

      Parameters

      • result: any
      • dreamClass: typeof Dream

      Returns RetType

    • Internal

      Used to hydrate dreams with the provided associations

      Parameters

      • dreams: Dream[]
      • association: AssociationStatement
      • preloadedDreamsAndWhatTheyPointTo: PreloadedDreamsAndWhatTheyPointTo[]

      Returns void

    • Retrieves the max value of the specified column for this Query

      await User.query().max('id')
      // 99

      Parameters

      • columnName: string

        a column name on the model

      Returns Promise<any>

      the max value of the specified column for this Query

    • Retrieves the min value of the specified column for this Query

      await User.query().min('id')
      // 1

      Parameters

      • columnName: string

        a column name on the model

      Returns Promise<any>

      the min value of the specified column for this Query

    • Returns a new Kysely SelectQueryBuilder instance to be used in a sub Query

      const records = await User.where({
      id: Post.query().nestedSelect('userId'),
      }).all()
      // [User{id: 1}, ...]

      Type Parameters

      • SimpleFieldType extends
            | number
            | typeof iterator
            | "match"
            | "toString"
            | "charAt"
            | "charCodeAt"
            | "concat"
            | "indexOf"
            | "lastIndexOf"
            | "localeCompare"
            | "replace"
            | "search"
            | "slice"
            | "split"
            | "substring"
            | "toLowerCase"
            | "toLocaleLowerCase"
            | "toUpperCase"
            | "toLocaleUpperCase"
            | "trim"
            | "length"
            | "substr"
            | "valueOf"
            | "codePointAt"
            | "includes"
            | "endsWith"
            | "normalize"
            | "repeat"
            | "startsWith"
            | "anchor"
            | "big"
            | "blink"
            | "bold"
            | "fixed"
            | "fontcolor"
            | "fontsize"
            | "italics"
            | "link"
            | "small"
            | "strike"
            | "sub"
            | "sup"
            | "padStart"
            | "padEnd"
            | "trimEnd"
            | "trimStart"
            | "trimLeft"
            | "trimRight"
            | "matchAll"
            | "replaceAll"
            | "at"
            | "toLocaleString"
      • PluckThroughFieldType

      Parameters

      Returns SelectQueryBuilder<any, any, any>

      A Kysely SelectQueryBuilder instance

    • Parameters

      • direction: OrderDir | null

      Returns (obj: OrderByItemBuilder) => OrderByItemBuilder

    • Returns the sql that would be executed by this Query

      User.where({ email: 'how@yadoin' }).sql()
      // {
      // query: {
      // kind: 'SelectQueryNode',
      // from: { kind: 'FromNode', froms: [Array] },
      // selections: [ [Object] ],
      // distinctOn: undefined,
      // joins: undefined,
      // groupBy: undefined,
      // orderBy: undefined,
      // where: { kind: 'WhereNode', where: [Object] },
      // frontModifiers: undefined,
      // endModifiers: undefined,
      // limit: undefined,
      // offset: undefined,
      // with: undefined,
      // having: undefined,
      // explain: undefined,
      // setOperations: undefined
      // },
      // sql: 'select "users".* from "users" where ("users"."email" = $1 and "users"."deleted_at" is null)',
      // parameters: [ 'how@yadoin' ]
      //}

      Returns CompiledQuery<{ [key: string]: any }>

      An object representing the underlying sql statement

    • Retrieves the sum value of the specified column for this Query

      await Game.query().sum('score')
      // 1

      Parameters

      • columnName: string

        a column name on the model

      Returns Promise<any>

      the sum of the values of the specified column for this Query

    • Internal

      Retrieves an array containing all records matching the Query. Be careful using this, since it will attempt to pull every record into memory at once. When querying might return a large number of records, consider using .findEach, which will pull the records in batches.

      await User.query().all()
      

      Parameters

      Returns Promise<DreamInstance[]>

      an array of dreams

    • destroys a dream, possibly implementing soft delete if reallyDestroy is false and the record being deleted implements soft delete.

      Parameters

      • dream: Dream

        the dream instance you wish to destroy

      • txn: DreamTransaction<Dream>

        a transaction to encapsulate, consistently provided by underlying dream mechanisms

      • reallyDestroy: boolean

        whether or not to reallyDestroy. If false, soft delete will be attempted when relevant

      Returns Promise<void>

    • Internal

      this is used by getColumnData to serialize enums

      Parameters

      • row: SchemaBuilderInformationSchemaRow

      Returns Capitalize<string>

    • Internal

      returns the foreign key type based on the primary key received. gives the driver the opportunity to switch i.e. bigserial to bigint.

      Parameters

      • primaryKey: LegacyCompatiblePrimaryKeyType

      Returns "bigint" | "integer" | "uuid"

    • This should build a new migration file in the migrations folder of your application. This will then need to be read and run whenever the migrate method is called. The filename should contain a timestamp at the front of the filename, so that it is sorted by date in the file tree, and, more importantly, so they can be run in order by your migration runner.

      Parameters

      • connectionName: string
      • migrationName: string
      • columnsWithTypes: string[]

      Returns Promise<void>

    • Parameters

      • connectionName: string
      • tableName: string
      • allTableAssociationData: { [key: string]: SchemaBuilderAssociationData }

      Returns Promise<{ [key: string]: SchemaBuilderColumnData }>

    • Internal

      this method is called when dream is initializing, and is used to configure the database to utilize custom type parsers for a variety of data types.

      Parameters

      • connectionName: string

        the name of the connection you are doing this for

      Returns Promise<void>

      void

    • defines the syncing behavior for dream and psychic, which is run whenever the sync command is called.

      Parameters

      • connectionName: string
      • onSync: () => void | Promise<void>
      • options: { schemaOnly?: boolean } = {}

      Returns Promise<void>