mirror of
https://github.com/The-Low-Code-Foundation/OpenNoodl.git
synced 2026-01-11 14:52:55 +01:00
feat: Improve the Noodl.Records.query typings API (#25)
This commit is contained in:
committed by
Richard Osborne
parent
c514c760e4
commit
509e967028
@@ -75,10 +75,10 @@ var SetDbModelPropertiedNodeDefinition = {
|
|||||||
_this.setError('Missing Record Id');
|
_this.setError('Missing Record Id');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var model = internal.model;
|
|
||||||
|
|
||||||
for (var i in internal.inputValues) {
|
const model = internal.model;
|
||||||
model.set(i, internal.inputValues[i], { resolve: true });
|
for (const key in internal.inputValues) {
|
||||||
|
model.set(key, internal.inputValues[key], { resolve: true });
|
||||||
}
|
}
|
||||||
|
|
||||||
CloudStore.forScope(_this.nodeScope.modelScope).save({
|
CloudStore.forScope(_this.nodeScope.modelScope).save({
|
||||||
|
|||||||
@@ -74,6 +74,59 @@ declare namespace Noodl {
|
|||||||
*/
|
*/
|
||||||
const Object: any;
|
const Object: any;
|
||||||
|
|
||||||
|
type RecordQuery<T> =
|
||||||
|
{
|
||||||
|
lessThan: T
|
||||||
|
} |
|
||||||
|
{
|
||||||
|
lessThanOrEqualTo: T
|
||||||
|
} |
|
||||||
|
{
|
||||||
|
greaterThan: T
|
||||||
|
} |
|
||||||
|
{
|
||||||
|
greaterThanOrEqualTo: T
|
||||||
|
} |
|
||||||
|
{
|
||||||
|
equalTo: T
|
||||||
|
} |
|
||||||
|
{
|
||||||
|
notEqualTo: T
|
||||||
|
} |
|
||||||
|
{
|
||||||
|
containedIn: T
|
||||||
|
} |
|
||||||
|
{
|
||||||
|
notContainedIn : T
|
||||||
|
} |
|
||||||
|
{
|
||||||
|
exists: T
|
||||||
|
} |
|
||||||
|
{
|
||||||
|
matchesRegex: T
|
||||||
|
} |
|
||||||
|
{
|
||||||
|
text: T
|
||||||
|
} |
|
||||||
|
{
|
||||||
|
idEqualTo: T
|
||||||
|
} |
|
||||||
|
{
|
||||||
|
idContainedIn: T
|
||||||
|
} |
|
||||||
|
{
|
||||||
|
pointsTo: T
|
||||||
|
} |
|
||||||
|
{
|
||||||
|
relatedTo: T
|
||||||
|
};
|
||||||
|
|
||||||
|
type RecordQueryField<T> = T extends RecordQuery<any> ?
|
||||||
|
{ [K in keyof T]: { [P in K]: T[P] } & Partial<Record<Exclude<keyof T, K>, never>> }[keyof T]
|
||||||
|
: never;
|
||||||
|
|
||||||
|
type RecordSortKey<T extends string> = (`${T}` | `-${T}`)[];
|
||||||
|
|
||||||
interface RecordsApi {
|
interface RecordsApi {
|
||||||
/**
|
/**
|
||||||
* This is an async function that will query the database using the query
|
* This is an async function that will query the database using the query
|
||||||
@@ -115,15 +168,17 @@ declare namespace Noodl {
|
|||||||
* })
|
* })
|
||||||
* ```
|
* ```
|
||||||
*/
|
*/
|
||||||
query(
|
query<TClassName extends RecordClassName>(
|
||||||
className: RecordClassName,
|
className: TClassName,
|
||||||
query?: any,
|
query?:
|
||||||
|
RecordQueryField<{ [K in keyof DatabaseSchema[TClassName]]: RecordQuery<any> }> |
|
||||||
|
{ and: RecordQueryField<{ [K in keyof DatabaseSchema[TClassName]]: RecordQuery<any> }>[] },
|
||||||
options?: {
|
options?: {
|
||||||
limit?: number;
|
limit?: number;
|
||||||
skip?: number;
|
skip?: number;
|
||||||
sort?: string[];
|
sort?: string | RecordSortKey<keyof DatabaseSchema[TClassName]>;
|
||||||
include?: any;
|
include?: string | (keyof DatabaseSchema[TClassName])[];
|
||||||
select?: any;
|
select?: string | (keyof DatabaseSchema[TClassName])[];
|
||||||
}
|
}
|
||||||
): Promise<any>;
|
): Promise<any>;
|
||||||
|
|
||||||
|
|||||||
@@ -131,6 +131,59 @@ declare namespace Noodl {
|
|||||||
*/
|
*/
|
||||||
const Events: EventsApi;
|
const Events: EventsApi;
|
||||||
|
|
||||||
|
type RecordQuery<T> =
|
||||||
|
{
|
||||||
|
lessThan: T
|
||||||
|
} |
|
||||||
|
{
|
||||||
|
lessThanOrEqualTo: T
|
||||||
|
} |
|
||||||
|
{
|
||||||
|
greaterThan: T
|
||||||
|
} |
|
||||||
|
{
|
||||||
|
greaterThanOrEqualTo: T
|
||||||
|
} |
|
||||||
|
{
|
||||||
|
equalTo: T
|
||||||
|
} |
|
||||||
|
{
|
||||||
|
notEqualTo: T
|
||||||
|
} |
|
||||||
|
{
|
||||||
|
containedIn: T
|
||||||
|
} |
|
||||||
|
{
|
||||||
|
notContainedIn : T
|
||||||
|
} |
|
||||||
|
{
|
||||||
|
exists: T
|
||||||
|
} |
|
||||||
|
{
|
||||||
|
matchesRegex: T
|
||||||
|
} |
|
||||||
|
{
|
||||||
|
text: T
|
||||||
|
} |
|
||||||
|
{
|
||||||
|
idEqualTo: T
|
||||||
|
} |
|
||||||
|
{
|
||||||
|
idContainedIn: T
|
||||||
|
} |
|
||||||
|
{
|
||||||
|
pointsTo: T
|
||||||
|
} |
|
||||||
|
{
|
||||||
|
relatedTo: T
|
||||||
|
};
|
||||||
|
|
||||||
|
type RecordQueryField<T> = T extends RecordQuery<any> ?
|
||||||
|
{ [K in keyof T]: { [P in K]: T[P] } & Partial<Record<Exclude<keyof T, K>, never>> }[keyof T]
|
||||||
|
: never;
|
||||||
|
|
||||||
|
type RecordSortKey<T extends string> = (`${T}` | `-${T}`)[];
|
||||||
|
|
||||||
interface RecordsApi {
|
interface RecordsApi {
|
||||||
/**
|
/**
|
||||||
* This is an async function that will query the database using the query
|
* This is an async function that will query the database using the query
|
||||||
@@ -172,15 +225,17 @@ declare namespace Noodl {
|
|||||||
* })
|
* })
|
||||||
* ```
|
* ```
|
||||||
*/
|
*/
|
||||||
query(
|
query<TClassName extends RecordClassName>(
|
||||||
className: RecordClassName,
|
className: TClassName,
|
||||||
query?: any,
|
query?:
|
||||||
|
RecordQueryField<{ [K in keyof DatabaseSchema[TClassName]]: RecordQuery<any> }> |
|
||||||
|
{ and: RecordQueryField<{ [K in keyof DatabaseSchema[TClassName]]: RecordQuery<any> }>[] },
|
||||||
options?: {
|
options?: {
|
||||||
limit?: number;
|
limit?: number;
|
||||||
skip?: number;
|
skip?: number;
|
||||||
sort?: string[];
|
sort?: string | RecordSortKey<keyof DatabaseSchema[TClassName]>;
|
||||||
include?: any;
|
include?: string | (keyof DatabaseSchema[TClassName])[];
|
||||||
select?: any;
|
select?: string | (keyof DatabaseSchema[TClassName])[];
|
||||||
}
|
}
|
||||||
): Promise<any>;
|
): Promise<any>;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user