query(query: string, ...args: any[]): Record<string, any>[]
Parameter | Type | Description |
query | string | Query Statement |
...args | any[ ] | Placeholder parameter used for querying. |
Type | Description |
Record<string, any>[] | Query the returned results, containing database data. |
import sql from 'pts/sql';// Create a database instance using new.const db = new sql.Database(sql.MySQL, "user:passwd@tcp(ip:port)/database")export default function () {let rows = db.query("SELECT * FROM user");// [{"id":1,"name":"zhangsan","age":23},{"id":2,"name":"lisi","age":2}]console.log(JSON.stringify(rows));}