Skip to content

Feature: Count method #189

Open
Open
@senpro-ingwersenk

Description

Is your feature request related to a problem?

Fighting with CBOR for unmarshalling has led me down to this:

	res, err := surrealdb.Query[[]struct {
		Count int `json:"count"`
	}](db, "select count() from $tableName;", map[string]interface{}{
		"tableName": tableName,
	})

Please implement a proper method for counting? :)

Describe the solution

Counting entries in a database table is one of the most essential parts. One shouldn't need to duke it out with CBOR just to get a proper count - at least, I think so. So, the solution I'd like to propose is to create a top-level function similiar to Insert and friends, but for Count(db *surrealdb.DB, table models.Table) int.

Alternative methods

Can't really think of one... sorry.

SurrealDB version

2.0.4

Contact Details

[email protected]

Is there an existing issue for this?

  • I have searched the existing issues

Code of Conduct

  • I agree to follow this project's Code of Conduct

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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