Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Count method #189

Open
2 tasks done
senpro-ingwersenk opened this issue Nov 19, 2024 · 0 comments
Open
2 tasks done

Feature: Count method #189

senpro-ingwersenk opened this issue Nov 19, 2024 · 0 comments

Comments

@senpro-ingwersenk
Copy link

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant