## Raw D1 Database query `client.d1.database.raw(stringdatabaseId, DatabaseRawParamsparams, RequestOptionsoptions?): SinglePage` **post** `/accounts/{account_id}/d1/database/{database_id}/raw` Returns the query result rows as arrays rather than objects. This is a performance-optimized version of the /query endpoint. ### Parameters - `databaseId: string` D1 database identifier (UUID). - `DatabaseRawParams = D1SingleQuery | MultipleQueries` - `DatabaseRawParamsBase` - `D1SingleQuery extends DatabaseRawParamsBase` - `MultipleQueries extends DatabaseRawParamsBase` ### Returns - `DatabaseRawResponse` - `meta?: Meta` - `changed_db?: boolean` Denotes if the database has been altered in some way, like deleting rows. - `changes?: number` Rough indication of how many rows were modified by the query, as provided by SQLite's `sqlite3_total_changes()`. - `duration?: number` The duration of the SQL query execution inside the database. Does not include any network communication. - `last_row_id?: number` The row ID of the last inserted row in a table with an `INTEGER PRIMARY KEY` as provided by SQLite. Tables created with `WITHOUT ROWID` do not populate this. - `rows_read?: number` Number of rows read during the SQL query execution, including indices (not all rows are necessarily returned). - `rows_written?: number` Number of rows written during the SQL query execution, including indices. - `served_by_colo?: string` The three letters airport code of the colo that handled the query. - `served_by_primary?: boolean` Denotes if the query has been handled by the database primary instance. - `served_by_region?: "WNAM" | "ENAM" | "WEUR" | 3 more` Region location hint of the database instance that handled the query. - `"WNAM"` - `"ENAM"` - `"WEUR"` - `"EEUR"` - `"APAC"` - `"OC"` - `size_after?: number` Size of the database after the query committed, in bytes. - `timings?: Timings` Various durations for the query. - `sql_duration_ms?: number` The duration of the SQL query execution inside the database. Does not include any network communication. - `results?: Results` - `columns?: Array` - `rows?: Array>` - `number` - `string` - `unknown` - `success?: boolean` ### Example ```node import Cloudflare from 'cloudflare'; const client = new Cloudflare({ apiToken: process.env['CLOUDFLARE_API_TOKEN'], // This is the default and can be omitted }); // Automatically fetches more pages as needed. for await (const databaseRawResponse of client.d1.database.raw( 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', { account_id: '023e105f4ecef8ad9ca31a8372d0c353', sql: 'SELECT * FROM myTable WHERE field = ? OR field = ?;', }, )) { console.log(databaseRawResponse.meta); } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "result": [ { "meta": { "changed_db": true, "changes": 0, "duration": 0, "last_row_id": 0, "rows_read": 0, "rows_written": 0, "served_by_colo": "LHR", "served_by_primary": true, "served_by_region": "EEUR", "size_after": 0, "timings": { "sql_duration_ms": 0 } }, "results": { "columns": [ "string" ], "rows": [ [ 0 ] ] }, "success": true } ], "success": true } ```