Comparing version 1.0.48 to 1.0.50
@@ -8,3 +8,3 @@ import { Pluck } from './helper_types'; | ||
}; | ||
export declare type Subquery<Schema extends OrmaSchema, Entities extends GetAllEntities<Schema>, RequireFrom extends boolean> = Entities extends any ? FieldObj<Schema, Entities> & SubqueryObj<Schema, Entities> & VirtualFieldObj<Schema, Entities> & FromObj<Schema, Entities, RequireFrom> & PaginationObj & GroupByObj<Schema, Entities> : never; | ||
export declare type Subquery<Schema extends OrmaSchema, Entities extends GetAllEntities<Schema>, RequireFrom extends boolean> = Entities extends any ? FieldObj<Schema, Entities> & SubqueryObj<Schema, Entities> & VirtualFieldObj<Schema, Entities> & FromObj<Schema, Entities, RequireFrom> & PaginationObj & GroupByObj<Schema, Entities> & OrderByObj<Schema, Entities> : never; | ||
export declare type FieldObj<Schema extends OrmaSchema, Entity extends GetAllEntities<Schema>> = { | ||
@@ -19,3 +19,3 @@ [Field in GetFields<Schema, Entity>]?: QueryField<Schema, Entity>; | ||
}; | ||
export declare type VirtualField<Schema extends OrmaSchema, Entity extends GetAllEntities<Schema>> = Subquery<Schema, Pluck<GetAllEdges<Schema, Entity>, 'to_entity'>, false> | QueryField<Schema, Entity> | Entity | number | GroupBy<Schema, Entity>; | ||
export declare type VirtualField<Schema extends OrmaSchema, Entity extends GetAllEntities<Schema>> = Subquery<Schema, Pluck<GetAllEdges<Schema, Entity>, 'to_entity'>, false> | QueryField<Schema, Entity> | Entity | number | GroupBy<Schema, Entity> | OrderBy<Schema, Entity>; | ||
export declare type FromObj<Schema extends OrmaSchema, Entity extends GetAllEntities<Schema>, RequireFrom extends boolean> = RequireFrom extends true ? { | ||
@@ -34,4 +34,15 @@ $from: Entity; | ||
}; | ||
export declare type GroupByObj<Schema extends OrmaSchema, Entity extends GetAllEntities<Schema>> = {}; | ||
declare type GroupBy<Schema extends OrmaSchema, Entity extends GetAllEntities<Schema>> = (GetFields<Schema, Entity> | Expression<Schema, Entity>)[]; | ||
export declare type GroupByObj<Schema extends OrmaSchema, Entity extends GetAllEntities<Schema>> = { | ||
$group_by?: GroupBy<Schema, Entity>; | ||
}; | ||
declare type FieldOrString<Schema extends OrmaSchema, Entity extends GetAllEntities<Schema>> = GetFields<Schema, Entity> | (string & {}); | ||
declare type GroupBy<Schema extends OrmaSchema, Entity extends GetAllEntities<Schema>> = (FieldOrString<Schema, Entity> | Expression<Schema, Entity>)[]; | ||
export declare type OrderByObj<Schema extends OrmaSchema, Entity extends GetAllEntities<Schema>> = { | ||
$order_by?: OrderBy<Schema, Entity>; | ||
}; | ||
declare type OrderBy<Schema extends OrmaSchema, Entity extends GetAllEntities<Schema>> = (FieldOrString<Schema, Entity> | { | ||
$asc: FieldOrString<Schema, Entity>; | ||
} | { | ||
$desc: FieldOrString<Schema, Entity>; | ||
} | Expression<Schema, Entity>)[]; | ||
export {}; |
@@ -83,3 +83,3 @@ "use strict"; | ||
$from: 'images', | ||
url: true | ||
url: true, | ||
}, | ||
@@ -94,5 +94,5 @@ }; | ||
products: { | ||
id: true | ||
} | ||
} | ||
id: true, | ||
}, | ||
}, | ||
}, | ||
@@ -102,5 +102,5 @@ }, | ||
products: { | ||
id: true | ||
} | ||
} | ||
id: true, | ||
}, | ||
}, | ||
}; | ||
@@ -124,3 +124,3 @@ // orma actually doesnt allow this, since in this case a $from clause must | ||
products: { | ||
$sum: 'id' | ||
$sum: 'id', | ||
}, | ||
@@ -148,4 +148,4 @@ }; | ||
$limit: 1, | ||
$offset: 2 | ||
} | ||
$offset: 2, | ||
}, | ||
}; | ||
@@ -156,5 +156,37 @@ } | ||
products: { | ||
$group_by: ['id', 'location_id'] | ||
$group_by: ['id', 'asdasdasd', { | ||
$sum: 'id' | ||
}], | ||
}, | ||
}; | ||
} | ||
{ | ||
const good = { | ||
products: { | ||
$order_by: [ | ||
'id', | ||
{ | ||
$asc: 'location_id', | ||
}, | ||
{ | ||
$desc: 'asdasdasdsad', | ||
}, | ||
'asdjaskdhasjd' | ||
], | ||
}, | ||
}; | ||
const bad1 = { | ||
products: { | ||
// @ts-expect-error | ||
$order_by: 'id' | ||
} | ||
}; | ||
const bad2 = { | ||
products: { | ||
$order_by: [{ | ||
// @ts-expect-error | ||
$not_a_real_keyword: 'id' | ||
}] | ||
} | ||
}; | ||
} | ||
@@ -161,0 +193,0 @@ // { |
{ | ||
"name": "orma", | ||
"version": "1.0.48", | ||
"version": "1.0.50", | ||
"description": "A declarative relational syncronous orm", | ||
@@ -5,0 +5,0 @@ "main": "build/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
283390
7128