不要怂,就是干,撸起袖子干!

Commit d5667e03 by Jordan Committed by Sushant

fix(types): change raw query return type to [unknown[],unknown] (#11368)

1 parent 398ae593
...@@ -1185,7 +1185,7 @@ export class Sequelize extends Hooks { ...@@ -1185,7 +1185,7 @@ export class Sequelize extends Hooks {
options: QueryOptionsWithModel options: QueryOptionsWithModel
): Promise<M[]>; ): Promise<M[]>;
public query<T extends object>(sql: string | { query: string; values: unknown[] }, options: QueryOptionsWithType<QueryTypes.SELECT>): Promise<T[]>; public query<T extends object>(sql: string | { query: string; values: unknown[] }, options: QueryOptionsWithType<QueryTypes.SELECT>): Promise<T[]>;
public query(sql: string | { query: string; values: unknown[] }, options?: QueryOptions | QueryOptionsWithType<QueryTypes.RAW>): Promise<unknown[]>; public query(sql: string | { query: string; values: unknown[] }, options?: QueryOptions | QueryOptionsWithType<QueryTypes.RAW>): Promise<[unknown[], unknown]>;
/** /**
* Get the fn for random based on the dialect * Get the fn for random based on the dialect
......
import { Config, Sequelize, Model } from 'sequelize'; import { Config, Sequelize, Model, QueryTypes } from 'sequelize';
import { Fn } from '../lib/utils'; import { Fn } from '../lib/utils';
Sequelize.useCLS({ Sequelize.useCLS({
...@@ -53,4 +53,10 @@ class Model1 extends Model{} ...@@ -53,4 +53,10 @@ class Model1 extends Model{}
class Model2 extends Model{} class Model2 extends Model{}
const myModel: typeof Model1 = sequelize.models.asd; const myModel: typeof Model1 = sequelize.models.asd;
myModel.hasOne(Model2) myModel.hasOne(Model2)
myModel.findAll(); myModel.findAll();
\ No newline at end of file
sequelize.query('SELECT * FROM `user`', { type: QueryTypes.RAW }).then(result => {
const data = result[0];
const arraysOnly = (a: any[]) => a;
arraysOnly(data);
});
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!