Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
356 changes: 216 additions & 140 deletions composer.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion example.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function getSSLPage($url) {

// Leave the platform you want uncommented
// $platform = 'client';
$platform = 'console';
$platform = 'server';
// $platform = 'server';

$version = '1.8.x';
Expand Down
18 changes: 18 additions & 0 deletions templates/android/library/src/main/java/io/package/Query.kt.twig
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,15 @@ class Query(
*/
fun createdAfter(value: String) = Query("createdAfter", null, listOf(value)).toJson()

/**
* Filter resources where document was created between start and end dates (inclusive).
*
* @param start The start date value.
* @param end The end date value.
* @returns The query string.
*/
fun createdBetween(start: String, end: String) = Query("createdBetween", null, listOf(start, end)).toJson()

/**
* Filter resources where document was updated before date.
*
Expand All @@ -270,6 +279,15 @@ class Query(
*/
fun updatedAfter(value: String) = Query("updatedAfter", null, listOf(value)).toJson()

/**
* Filter resources where document was updated between start and end dates (inclusive).
*
* @param start The start date value.
* @param end The end date value.
* @returns The query string.
*/
fun updatedBetween(start: String, end: String) = Query("updatedBetween", null, listOf(start, end)).toJson()

/**
* Combine multiple queries using logical OR operator.
*
Expand Down
8 changes: 8 additions & 0 deletions templates/dart/lib/query.dart.twig
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ class Query {
static String createdAfter(String value) =>
Query._('createdAfter', null, value).toString();

/// Filter resources where document was created between [start] and [end] (inclusive).
static String createdBetween(String start, String end) =>
Query._('createdBetween', null, [start, end]).toString();

/// Filter resources where document was updated before [value].
static String updatedBefore(String value) =>
Query._('updatedBefore', null, value).toString();
Expand All @@ -119,6 +123,10 @@ class Query {
static String updatedAfter(String value) =>
Query._('updatedAfter', null, value).toString();

/// Filter resources where document was updated between [start] and [end] (inclusive).
static String updatedBetween(String start, String end) =>
Query._('updatedBetween', null, [start, end]).toString();

static String or(List<String> queries) => Query._(
'or',
null,
Expand Down
14 changes: 14 additions & 0 deletions templates/dart/test/query_test.dart.twig
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,13 @@ void main() {
expect(query['method'], 'createdAfter');
});

test('returns createdBetween', () {
final query = jsonDecode(Query.createdBetween('2023-01-01', '2023-12-31'));
expect(query['attribute'], null);
expect(query['values'], ['2023-01-01', '2023-12-31']);
expect(query['method'], 'createdBetween');
});

test('returns updatedBefore', () {
final query = jsonDecode(Query.updatedBefore('2023-01-01'));
expect(query['attribute'], null);
Expand All @@ -296,5 +303,12 @@ void main() {
expect(query['values'], ['2023-01-01']);
expect(query['method'], 'updatedAfter');
});

test('returns updatedBetween', () {
final query = jsonDecode(Query.updatedBetween('2023-01-01', '2023-12-31'));
expect(query['attribute'], null);
expect(query['values'], ['2023-01-01', '2023-12-31']);
expect(query['method'], 'updatedBetween');
});
}

20 changes: 20 additions & 0 deletions templates/deno/src/query.ts.twig
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,16 @@ export class Query {
static createdAfter = (value: string): string =>
new Query("createdAfter", undefined, value).toString();

/**
* Filter resources where document was created between dates.
*
* @param {string} start
* @param {string} end
* @returns {string}
*/
static createdBetween = (start: string, end: string): string =>
new Query("createdBetween", undefined, [start, end] as QueryTypesList).toString();

/**
* Filter resources where document was updated before date.
*
Expand All @@ -191,6 +201,16 @@ export class Query {
static updatedAfter = (value: string): string =>
new Query("updatedAfter", undefined, value).toString();

/**
* Filter resources where document was updated between dates.
*
* @param {string} start
* @param {string} end
* @returns {string}
*/
static updatedBetween = (start: string, end: string): string =>
new Query("updatedBetween", undefined, [start, end] as QueryTypesList).toString();

static or = (queries: string[]) =>
new Query("or", undefined, queries.map((query) => JSON.parse(query))).toString();

Expand Down
10 changes: 10 additions & 0 deletions templates/deno/test/query.test.ts.twig
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,11 @@ describe('Query', () => {
`{"method":"createdAfter","values":["2023-01-01"]}`,
));

test('createdBetween', () => assertEquals(
Query.createdBetween('2023-01-01', '2023-12-31').toString(),
`{"method":"createdBetween","values":["2023-01-01","2023-12-31"]}`,
));

test('updatedBefore', () => assertEquals(
Query.updatedBefore('2023-01-01').toString(),
`{"method":"updatedBefore","values":["2023-01-01"]}`,
Expand All @@ -227,4 +232,9 @@ describe('Query', () => {
Query.updatedAfter('2023-01-01').toString(),
`{"method":"updatedAfter","values":["2023-01-01"]}`,
));

test('updatedBetween', () => assertEquals(
Query.updatedBetween('2023-01-01', '2023-12-31').toString(),
`{"method":"updatedBetween","values":["2023-01-01","2023-12-31"]}`,
));
})
8 changes: 8 additions & 0 deletions templates/dotnet/Package/Query.cs.twig
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,10 @@ namespace {{ spec.title | caseUcfirst }}
return new Query("createdAfter", null, value).ToString();
}

public static string CreatedBetween(string start, string end) {
return new Query("createdBetween", null, new List<string> { start, end }).ToString();
}

public static string UpdatedBefore(string value) {
return new Query("updatedBefore", null, value).ToString();
}
Expand All @@ -194,6 +198,10 @@ namespace {{ spec.title | caseUcfirst }}
return new Query("updatedAfter", null, value).ToString();
}

public static string UpdatedBetween(string start, string end) {
return new Query("updatedBetween", null, new List<string> { start, end }).ToString();
}

public static string Or(List<string> queries) {
return new Query("or", null, queries.Select(q => JsonSerializer.Deserialize<Query>(q, Client.DeserializerOptions)).ToList()).ToString();
}
Expand Down
16 changes: 16 additions & 0 deletions templates/go/query.go.twig
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,14 @@ func CreatedAfter(value interface{}) string {
})
}

func CreatedBetween(start, end interface{}) string {
values := []interface{}{start, end}
return parseQuery(queryOptions{
Method: "createdBetween",
Values: &values,
})
}

func UpdatedBefore(value interface{}) string {
values := toArray(value)
return parseQuery(queryOptions{
Expand All @@ -233,6 +241,14 @@ func UpdatedAfter(value interface{}) string {
})
}

func UpdatedBetween(start, end interface{}) string {
values := []interface{}{start, end}
return parseQuery(queryOptions{
Method: "updatedBetween",
Values: &values,
})
}

func Select(attributes interface{}) string {
values := toArray(attributes)
return parseQuery(queryOptions{
Expand Down
4 changes: 4 additions & 0 deletions templates/kotlin/src/main/kotlin/io/appwrite/Query.kt.twig
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,14 @@ class Query(

fun createdAfter(value: String) = Query("createdAfter", null, listOf(value)).toJson()

fun createdBetween(start: String, end: String) = Query("createdBetween", null, listOf(start, end)).toJson()

fun updatedBefore(value: String) = Query("updatedBefore", null, listOf(value)).toJson()

fun updatedAfter(value: String) = Query("updatedAfter", null, listOf(value)).toJson()

fun updatedBetween(start: String, end: String) = Query("updatedBetween", null, listOf(start, end)).toJson()

fun or(queries: List<String>) = Query("or", null, queries.map { it.fromJson<Query>() }).toJson()

fun and(queries: List<String>) = Query("and", null, queries.map { it.fromJson<Query>() }).toJson()
Expand Down
24 changes: 24 additions & 0 deletions templates/php/src/Query.php.twig
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,18 @@ class Query implements \JsonSerializable
return (new Query('createdAfter', null, $value))->__toString();
}

/**
* Created Between
*
* @param string $start
* @param string $end
* @return string
*/
public static function createdBetween(string $start, string $end): string
{
return (new Query('createdBetween', null, [$start, $end]))->__toString();
}

/**
* Updated Before
*
Expand All @@ -372,6 +384,18 @@ class Query implements \JsonSerializable
return (new Query('updatedAfter', null, $value))->__toString();
}

/**
* Updated Between
*
* @param string $start
* @param string $end
* @return string
*/
public static function updatedBetween(string $start, string $end): string
{
return (new Query('updatedBetween', null, [$start, $end]))->__toString();
}

/**
* Or
*
Expand Down
8 changes: 8 additions & 0 deletions templates/php/tests/QueryTest.php.twig
Original file line number Diff line number Diff line change
Expand Up @@ -183,11 +183,19 @@ final class QueryTest extends TestCase {
$this->assertSame('createdAfter("2023-01-01")', Query::createdAfter('2023-01-01'));
}

public function testCreatedBetween(): void {
$this->assertSame('{"method":"createdBetween","values":["2023-01-01","2023-12-31"]}', Query::createdBetween('2023-01-01', '2023-12-31'));
}

public function testUpdatedBefore(): void {
$this->assertSame('updatedBefore("2023-01-01")', Query::updatedBefore('2023-01-01'));
}

public function testUpdatedAfter(): void {
$this->assertSame('updatedAfter("2023-01-01")', Query::updatedAfter('2023-01-01'));
}

public function testUpdatedBetween(): void {
$this->assertSame('{"method":"updatedBetween","values":["2023-01-01","2023-12-31"]}', Query::updatedBetween('2023-01-01', '2023-12-31'));
}
}
8 changes: 8 additions & 0 deletions templates/python/package/query.py.twig
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ class Query():
def created_after(value):
return str(Query("createdAfter", None, value))

@staticmethod
def created_between(start, end):
return str(Query("createdBetween", None, [start, end]))

@staticmethod
def updated_before(value):
return str(Query("updatedBefore", None, value))
Expand All @@ -135,6 +139,10 @@ class Query():
def updated_after(value):
return str(Query("updatedAfter", None, value))

@staticmethod
def updated_between(start, end):
return str(Query("updatedBetween", None, [start, end]))

@staticmethod
def or_queries(queries):
return str(Query("or", None, [json.loads(query) for query in queries]))
Expand Down
20 changes: 20 additions & 0 deletions templates/react-native/src/query.ts.twig
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,16 @@ export class Query {
static createdAfter = (value: string): string =>
new Query("createdAfter", undefined, value).toString();

/**
* Filter resources where document was created between dates.
*
* @param {string} start
* @param {string} end
* @returns {string}
*/
static createdBetween = (start: string, end: string): string =>
new Query("createdBetween", undefined, [start, end] as QueryTypesList).toString();

/**
* Filter resources where document was updated before date.
*
Expand All @@ -188,6 +198,16 @@ export class Query {
static updatedAfter = (value: string): string =>
new Query("updatedAfter", undefined, value).toString();

/**
* Filter resources where document was updated between dates.
*
* @param {string} start
* @param {string} end
* @returns {string}
*/
static updatedBetween = (start: string, end: string): string =>
new Query("updatedBetween", undefined, [start, end] as QueryTypesList).toString();

static or = (queries: string[]) =>
new Query("or", undefined, queries.map((query) => JSON.parse(query))).toString();

Expand Down
8 changes: 8 additions & 0 deletions templates/ruby/lib/container/query.rb.twig
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,10 @@ module {{spec.title | caseUcfirst}}
return Query.new("createdAfter", nil, value).to_s
end

def created_between(start, ending)
return Query.new("createdBetween", nil, [start, ending]).to_s
end

def updated_before(value)
return Query.new("updatedBefore", nil, value).to_s
end
Expand All @@ -144,6 +148,10 @@ module {{spec.title | caseUcfirst}}
return Query.new("updatedAfter", nil, value).to_s
end

def updated_between(start, ending)
return Query.new("updatedBetween", nil, [start, ending]).to_s
end

def or(queries)
return Query.new("or", nil, queries.map { |query| JSON.parse(query) }).to_s
end
Expand Down
14 changes: 14 additions & 0 deletions templates/swift/Sources/Query.swift.twig
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,13 @@ public struct Query : Codable, CustomStringConvertible {
).description
}

public static func createdBetween(_ start: String, _ end: String) -> String {
return Query(
method: "createdBetween",
values: [start, end]
).description
}

public static func updatedBefore(_ value: String) -> String {
return Query(
method: "updatedBefore",
Expand All @@ -368,6 +375,13 @@ public struct Query : Codable, CustomStringConvertible {
).description
}

public static func updatedBetween(_ start: String, _ end: String) -> String {
return Query(
method: "updatedBetween",
values: [start, end]
).description
}

public static func or(_ queries: [String]) -> String {
let decoder = JSONDecoder()
let decodedQueries = queries.compactMap { queryStr -> Query? in
Expand Down
Loading