Skip to content

The function ***count*** stopped working #23

@Amantura

Description

@Amantura
"drizzle-orm": "^1.0.0-rc.1",
"drizzle-kit": "^1.0.0-rc.1",
"drizzle-plus": "^1.0.0-rc.4"
class extends QueryPromise {
  constructor(table, filter, session, dialect) {
    super();
    this.table = table;
    this.filter = filter;
    this.session = session;
    this.dialect = dialect;
  }
  async execute() {
    const query = this.getSQL();
    const [result] = await this.session.all(query);  // error: "this.session.all is not a function"
    return Number(result.count);
  }
  toSQL() {
    return this.dialect.sqlToQuery(this.getSQL());
  }
  getSQL() {
    const query = sql`select count(*) AS "count" from ${this.table}`;
    if (this.filter) {
      query.append(sql` where ${this.filter}`);
    }
    return query;
  }
  // Used by our nest() implementation.
  _getQuery() {
    return {
      sql: this.getSQL(),
      selection: [{ key: "count", field: sql`count(*)`.mapWith(Number) }]
    };
  }
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions