tspace-mysql 1.4.4 → 1.4.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +112 -90
- package/dist/lib/connection/index.d.ts +1 -1
- package/dist/lib/connection/index.js +9 -10
- package/dist/lib/connection/options.js +1 -1
- package/dist/lib/constants/index.js +3 -2
- package/dist/lib/tspace/Abstract/AbstractBuilder.d.ts +41 -42
- package/dist/lib/tspace/Abstract/AbstractDB.d.ts +2 -4
- package/dist/lib/tspace/Abstract/AbstractModel.d.ts +5 -7
- package/dist/lib/tspace/Blueprint.d.ts +9 -3
- package/dist/lib/tspace/Blueprint.js +15 -8
- package/dist/lib/tspace/Builder.d.ts +92 -96
- package/dist/lib/tspace/Builder.js +220 -142
- package/dist/lib/tspace/Model.d.ts +45 -139
- package/dist/lib/tspace/Model.js +78 -180
- package/dist/lib/tspace/Schema.js +7 -5
- package/package.json +1 -1
|
@@ -140,7 +140,7 @@ declare class Model extends AbstractModel {
|
|
|
140
140
|
* @example
|
|
141
141
|
* class User extends Model {
|
|
142
142
|
* constructor() {
|
|
143
|
-
* this.useSoftDelete('
|
|
143
|
+
* this.useSoftDelete('deletedAt')
|
|
144
144
|
* }
|
|
145
145
|
* }
|
|
146
146
|
* @return {this} this
|
|
@@ -283,7 +283,7 @@ declare class Model extends AbstractModel {
|
|
|
283
283
|
* @param {string} sql
|
|
284
284
|
* @return {this} this
|
|
285
285
|
*/
|
|
286
|
-
protected queryStatement(sql: string): Promise<
|
|
286
|
+
protected queryStatement(sql: string): Promise<any[]>;
|
|
287
287
|
/**
|
|
288
288
|
*
|
|
289
289
|
* execute the query using raw sql syntax actions for insert update and delete
|
|
@@ -317,12 +317,10 @@ declare class Model extends AbstractModel {
|
|
|
317
317
|
ignoreSoftDelete(condition?: boolean): this;
|
|
318
318
|
/**
|
|
319
319
|
* Assign build in function to result of data
|
|
320
|
-
* @param {
|
|
320
|
+
* @param {Record} func
|
|
321
321
|
* @return {this} this
|
|
322
322
|
*/
|
|
323
|
-
registry(func:
|
|
324
|
-
[key: string]: Function;
|
|
325
|
-
}): this;
|
|
323
|
+
registry(func: Record<string, Function>): this;
|
|
326
324
|
/**
|
|
327
325
|
*
|
|
328
326
|
* Use relations in registry of model return result of relation query
|
|
@@ -696,81 +694,9 @@ declare class Model extends AbstractModel {
|
|
|
696
694
|
* restore data in trashed
|
|
697
695
|
* @return {promise}
|
|
698
696
|
*/
|
|
699
|
-
restore(): Promise<any>;
|
|
697
|
+
restore(): Promise<any[]>;
|
|
700
698
|
toTableName(): string;
|
|
701
699
|
toTableNameAndColumn(column: string): string;
|
|
702
|
-
/**
|
|
703
|
-
*
|
|
704
|
-
* @override Method
|
|
705
|
-
* @return {string}
|
|
706
|
-
*/
|
|
707
|
-
toString(): string;
|
|
708
|
-
/**
|
|
709
|
-
*
|
|
710
|
-
* @override Method
|
|
711
|
-
* @return {string}
|
|
712
|
-
*/
|
|
713
|
-
toSQL(): string;
|
|
714
|
-
/**
|
|
715
|
-
*
|
|
716
|
-
* @override Method
|
|
717
|
-
* @return {string}
|
|
718
|
-
*/
|
|
719
|
-
toRawSQL(): string;
|
|
720
|
-
/**
|
|
721
|
-
*
|
|
722
|
-
* @override Method
|
|
723
|
-
* @return {promise<string>}
|
|
724
|
-
*/
|
|
725
|
-
toJSON(): Promise<string>;
|
|
726
|
-
/**
|
|
727
|
-
*
|
|
728
|
-
* @override Method
|
|
729
|
-
* @param {string=} column [column=id]
|
|
730
|
-
* @return {promise<Array>}
|
|
731
|
-
*/
|
|
732
|
-
toArray(column?: string): Promise<Array<any>>;
|
|
733
|
-
/**
|
|
734
|
-
*
|
|
735
|
-
* @override Method
|
|
736
|
-
* @param {string=} column [column=id]
|
|
737
|
-
* @return {promise<number>}
|
|
738
|
-
*/
|
|
739
|
-
avg(column?: string): Promise<number>;
|
|
740
|
-
/**
|
|
741
|
-
*
|
|
742
|
-
* @override Method
|
|
743
|
-
* @param {string} column [column=id]
|
|
744
|
-
* @return {promise<number>}
|
|
745
|
-
*/
|
|
746
|
-
sum(column?: string): Promise<number>;
|
|
747
|
-
/**
|
|
748
|
-
*
|
|
749
|
-
* @override Method
|
|
750
|
-
* @param {string=} column [column=id]
|
|
751
|
-
* @return {promise<number>}
|
|
752
|
-
*/
|
|
753
|
-
max(column?: string): Promise<number>;
|
|
754
|
-
/**
|
|
755
|
-
*
|
|
756
|
-
* @override Method
|
|
757
|
-
* @param {string=} column [column=id]
|
|
758
|
-
* @return {promise<number>}
|
|
759
|
-
*/
|
|
760
|
-
min(column?: string): Promise<number>;
|
|
761
|
-
/**
|
|
762
|
-
*
|
|
763
|
-
* @override Method
|
|
764
|
-
* @param {string=} column [column=id]
|
|
765
|
-
* @return {promise<number>}
|
|
766
|
-
*/
|
|
767
|
-
count(column?: string): Promise<number>;
|
|
768
|
-
/**
|
|
769
|
-
*
|
|
770
|
-
* execute data return result is exists
|
|
771
|
-
* @return {promise<boolean>}
|
|
772
|
-
*/
|
|
773
|
-
exists(): Promise<boolean>;
|
|
774
700
|
/**
|
|
775
701
|
* delete data from the database
|
|
776
702
|
* @override Method
|
|
@@ -780,51 +706,39 @@ declare class Model extends AbstractModel {
|
|
|
780
706
|
/**
|
|
781
707
|
*
|
|
782
708
|
* @override Method
|
|
783
|
-
* @return {promise<
|
|
709
|
+
* @return {promise<Record<string,any> | null>}
|
|
784
710
|
*/
|
|
785
|
-
first(): Promise<
|
|
786
|
-
[key: string]: any;
|
|
787
|
-
} | null>;
|
|
711
|
+
first(): Promise<Record<string, any> | null>;
|
|
788
712
|
/**
|
|
789
713
|
*
|
|
790
714
|
* @override Method
|
|
791
|
-
* @return {promise<
|
|
715
|
+
* @return {promise<Record<string,any> | null>}
|
|
792
716
|
*/
|
|
793
|
-
findOne(): Promise<
|
|
794
|
-
[key: string]: any;
|
|
795
|
-
} | null>;
|
|
717
|
+
findOne(): Promise<Record<string, any> | null>;
|
|
796
718
|
/**
|
|
797
719
|
*
|
|
798
720
|
* @override Method
|
|
799
721
|
* @return {promise<object | Error>}
|
|
800
722
|
*/
|
|
801
|
-
firstOrError(message: string, options?:
|
|
802
|
-
[key: string]: any;
|
|
803
|
-
}): Promise<{
|
|
804
|
-
[key: string]: any;
|
|
805
|
-
}>;
|
|
723
|
+
firstOrError(message: string, options?: Record<string, any>): Promise<Record<string, any>>;
|
|
806
724
|
/**
|
|
807
725
|
*
|
|
808
726
|
* @override Method
|
|
809
727
|
* @return {promise<any>}
|
|
810
728
|
*/
|
|
811
|
-
findOneOrError(message: string, options?:
|
|
812
|
-
[key: string]: any;
|
|
813
|
-
}): Promise<{
|
|
814
|
-
[key: string]: any;
|
|
815
|
-
}>;
|
|
729
|
+
findOneOrError(message: string, options?: Record<string, any>): Promise<Record<string, any>>;
|
|
816
730
|
/**
|
|
817
731
|
*
|
|
818
732
|
* @override Method
|
|
819
733
|
* @return {promise<array>}
|
|
820
734
|
*/
|
|
821
|
-
get(): Promise<
|
|
735
|
+
get(): Promise<any[]>;
|
|
822
736
|
/**
|
|
823
737
|
*
|
|
824
738
|
* @override Method
|
|
825
739
|
* @return {promise<array>}
|
|
826
740
|
*/
|
|
827
|
-
findMany(): Promise<
|
|
741
|
+
findMany(): Promise<any[]>;
|
|
828
742
|
/**
|
|
829
743
|
*
|
|
830
744
|
* @override Method
|
|
@@ -855,16 +769,23 @@ declare class Model extends AbstractModel {
|
|
|
855
769
|
* @param {string} column
|
|
856
770
|
* @return {Promise<array>}
|
|
857
771
|
*/
|
|
858
|
-
getGroupBy(column: string): Promise<
|
|
772
|
+
getGroupBy(column: string): Promise<any[]>;
|
|
859
773
|
/**
|
|
860
774
|
*
|
|
861
775
|
* update data in the database
|
|
776
|
+
* @param {object} data
|
|
777
|
+
* @param {array?} updateNotExists options for except update some records in your ${data}
|
|
778
|
+
* @return {this} this
|
|
779
|
+
*/
|
|
780
|
+
update(data: Record<string, any>, updateNotExists?: string[]): this;
|
|
781
|
+
/**
|
|
782
|
+
*
|
|
862
783
|
* @override Method
|
|
863
784
|
* @param {object} data
|
|
864
785
|
* @return {this} this
|
|
865
786
|
*/
|
|
866
|
-
|
|
867
|
-
length?:
|
|
787
|
+
updateNotExists(data: Record<string, any> & {
|
|
788
|
+
length?: unknown;
|
|
868
789
|
}): this;
|
|
869
790
|
/**
|
|
870
791
|
*
|
|
@@ -872,72 +793,56 @@ declare class Model extends AbstractModel {
|
|
|
872
793
|
* @param {object} data for insert
|
|
873
794
|
* @return {this} this
|
|
874
795
|
*/
|
|
875
|
-
insert(data: Record<string, any>
|
|
876
|
-
length?: never;
|
|
877
|
-
}): this;
|
|
796
|
+
insert(data: Record<string, any>): this;
|
|
878
797
|
/**
|
|
879
798
|
*
|
|
880
799
|
* @override Method
|
|
881
800
|
* @param {object} data for insert
|
|
882
801
|
* @return {this} this
|
|
883
802
|
*/
|
|
884
|
-
create(data: Record<string, any>
|
|
885
|
-
length?: never;
|
|
886
|
-
}): this;
|
|
803
|
+
create(data: Record<string, any>): this;
|
|
887
804
|
/**
|
|
888
805
|
*
|
|
889
806
|
* @override Method
|
|
890
807
|
* @param {object} data for update or create
|
|
891
808
|
* @return {this} this
|
|
892
809
|
*/
|
|
893
|
-
updateOrCreate(data: Record<string, any>
|
|
894
|
-
length?: never;
|
|
895
|
-
}): this;
|
|
810
|
+
updateOrCreate(data: Record<string, any>): this;
|
|
896
811
|
/**
|
|
897
812
|
*
|
|
898
813
|
* @override Method
|
|
899
814
|
* @param {object} data for update or create
|
|
900
815
|
* @return {this} this
|
|
901
816
|
*/
|
|
902
|
-
updateOrInsert(data: Record<string, any>
|
|
903
|
-
length?: never;
|
|
904
|
-
}): this;
|
|
817
|
+
updateOrInsert(data: Record<string, any>): this;
|
|
905
818
|
/**
|
|
906
819
|
*
|
|
907
820
|
* @override Method
|
|
908
821
|
* @param {object} data for update or create
|
|
909
822
|
* @return {this} this
|
|
910
823
|
*/
|
|
911
|
-
insertOrUpdate(data: Record<string, any>
|
|
912
|
-
length?: never;
|
|
913
|
-
}): this;
|
|
824
|
+
insertOrUpdate(data: Record<string, any>): this;
|
|
914
825
|
/**
|
|
915
826
|
*
|
|
916
827
|
* @override Method
|
|
917
828
|
* @param {object} data for update or create
|
|
918
829
|
* @return {this} this
|
|
919
830
|
*/
|
|
920
|
-
createOrUpdate(data: Record<string, any>
|
|
921
|
-
length?: never;
|
|
922
|
-
}): this;
|
|
831
|
+
createOrUpdate(data: Record<string, any>): this;
|
|
923
832
|
/**
|
|
924
833
|
*
|
|
925
834
|
* @override Method
|
|
926
835
|
* @param {object} data for create
|
|
927
836
|
* @return {this} this
|
|
928
837
|
*/
|
|
929
|
-
createOrSelect(data: Record<string, any>
|
|
930
|
-
length?: never;
|
|
931
|
-
}): this;
|
|
838
|
+
createOrSelect(data: Record<string, any>): this;
|
|
932
839
|
/**
|
|
933
840
|
*
|
|
934
841
|
* @override Method
|
|
935
842
|
* @param {object} data for update or create
|
|
936
843
|
* @return {this} this
|
|
937
844
|
*/
|
|
938
|
-
insertOrSelect(data: Record<string, any>
|
|
939
|
-
length?: never;
|
|
940
|
-
}): this;
|
|
845
|
+
insertOrSelect(data: Record<string, any>): this;
|
|
941
846
|
/**
|
|
942
847
|
*
|
|
943
848
|
* insert multiple data into the database
|
|
@@ -945,7 +850,7 @@ declare class Model extends AbstractModel {
|
|
|
945
850
|
* @param {array<object>} data create multiple data
|
|
946
851
|
* @return {this} this this
|
|
947
852
|
*/
|
|
948
|
-
createMultiple(data:
|
|
853
|
+
createMultiple(data: Record<string, any>[]): this;
|
|
949
854
|
/**
|
|
950
855
|
*
|
|
951
856
|
* insert muliple data into the database
|
|
@@ -953,27 +858,21 @@ declare class Model extends AbstractModel {
|
|
|
953
858
|
* @param {array<object>} data create multiple data
|
|
954
859
|
* @return {this} this this
|
|
955
860
|
*/
|
|
956
|
-
insertMultiple(data:
|
|
861
|
+
insertMultiple(data: Record<string, any>[]): this;
|
|
957
862
|
/**
|
|
958
863
|
*
|
|
959
864
|
* @param {object} data create not exists data
|
|
960
865
|
* @override Method
|
|
961
866
|
* @return {this} this this
|
|
962
867
|
*/
|
|
963
|
-
createNotExists(data: Record<string, any>
|
|
964
|
-
length?: never;
|
|
965
|
-
}): this;
|
|
868
|
+
createNotExists(data: Record<string, any>): this;
|
|
966
869
|
/**
|
|
967
870
|
*
|
|
968
871
|
* @param {object} data create not exists data
|
|
969
872
|
* @override Method
|
|
970
873
|
* @return {this} this this
|
|
971
874
|
*/
|
|
972
|
-
insertNotExists(data:
|
|
973
|
-
[key: string]: any;
|
|
974
|
-
} & {
|
|
975
|
-
length?: never;
|
|
976
|
-
}): this;
|
|
875
|
+
insertNotExists(data: Record<string, any>): this;
|
|
977
876
|
/**
|
|
978
877
|
*
|
|
979
878
|
* get schema from table
|
|
@@ -985,12 +884,13 @@ declare class Model extends AbstractModel {
|
|
|
985
884
|
/**
|
|
986
885
|
*
|
|
987
886
|
* @override Method
|
|
988
|
-
* @return {Promise<Record<string,any> |
|
|
887
|
+
* @return {Promise<Record<string,any> | any[] | null | undefined>}
|
|
989
888
|
*/
|
|
990
|
-
save(): Promise<Record<string, any> |
|
|
889
|
+
save(): Promise<Record<string, any> | any[] | null | undefined>;
|
|
991
890
|
/**
|
|
992
891
|
*
|
|
993
892
|
* fake data into to this table
|
|
893
|
+
* @override Method
|
|
994
894
|
* @param {number} rows number of rows
|
|
995
895
|
* @return {promise<any>}
|
|
996
896
|
*/
|
|
@@ -1002,7 +902,13 @@ declare class Model extends AbstractModel {
|
|
|
1002
902
|
private _tableName;
|
|
1003
903
|
private _valueInRelation;
|
|
1004
904
|
private _handleSoftDelete;
|
|
1005
|
-
|
|
905
|
+
/**
|
|
906
|
+
*
|
|
907
|
+
* generate sql statements
|
|
908
|
+
* @override
|
|
909
|
+
* @return {string} string generated query string
|
|
910
|
+
*/
|
|
911
|
+
protected _buildQueryStatement(): string;
|
|
1006
912
|
private _showOnly;
|
|
1007
913
|
private _validateSchema;
|
|
1008
914
|
private _execute;
|