pr feedback
This commit is contained in:
parent
6374a04ed4
commit
e578b05058
|
@ -6,8 +6,8 @@
|
||||||
#include "js_object.hpp"
|
#include "js_object.hpp"
|
||||||
#include "js_results.hpp"
|
#include "js_results.hpp"
|
||||||
#include "js_util.hpp"
|
#include "js_util.hpp"
|
||||||
#include "object_accessor.hpp"
|
|
||||||
|
|
||||||
|
#include "object_accessor.hpp"
|
||||||
#include "parser.hpp"
|
#include "parser.hpp"
|
||||||
#include "query_builder.hpp"
|
#include "query_builder.hpp"
|
||||||
|
|
||||||
|
@ -210,18 +210,8 @@ JSValueRef ListFiltered(JSContextRef ctx, JSObjectRef function, JSObjectRef this
|
||||||
RJSValidateArgumentCountIsAtLeast(argumentCount, 1);
|
RJSValidateArgumentCountIsAtLeast(argumentCount, 1);
|
||||||
SharedRealm sharedRealm = *RJSGetInternal<SharedRealm *>(thisObject);
|
SharedRealm sharedRealm = *RJSGetInternal<SharedRealm *>(thisObject);
|
||||||
|
|
||||||
std::string queryString = RJSValidatedStringForValue(ctx, arguments[0], "predicate");
|
|
||||||
std::vector<JSValueRef> args;
|
|
||||||
for (size_t i = 1; i < argumentCount; i++) {
|
|
||||||
args.push_back(arguments[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
parser::Predicate predicate = parser::parse(queryString);
|
|
||||||
query_builder::ArgumentConverter<JSValueRef, JSContextRef> arguments(ctx, args);
|
|
||||||
Query query = list->get_query();
|
Query query = list->get_query();
|
||||||
query_builder::apply_predicate(query, predicate, arguments, *sharedRealm->config().schema, list->get_object_schema().name);
|
return RJSResultsCreate(ctx, sharedRealm, list->get_object_schema(), query, argumentCount, arguments);
|
||||||
|
|
||||||
return RJSResultsCreate(ctx, sharedRealm, list->get_object_schema(), query);
|
|
||||||
}
|
}
|
||||||
catch (std::exception &exp) {
|
catch (std::exception &exp) {
|
||||||
if (jsException) {
|
if (jsException) {
|
||||||
|
|
|
@ -125,19 +125,8 @@ JSValueRef ResultsFiltered(JSContextRef ctx, JSObjectRef function, JSObjectRef t
|
||||||
RJSValidateArgumentCountIsAtLeast(argumentCount, 1);
|
RJSValidateArgumentCountIsAtLeast(argumentCount, 1);
|
||||||
SharedRealm sharedRealm = *RJSGetInternal<SharedRealm *>(thisObject);
|
SharedRealm sharedRealm = *RJSGetInternal<SharedRealm *>(thisObject);
|
||||||
|
|
||||||
std::string queryString = RJSValidatedStringForValue(ctx, arguments[0], "predicate");
|
|
||||||
std::vector<JSValueRef> args;
|
|
||||||
for (size_t i = 1; i < argumentCount; i++) {
|
|
||||||
args.push_back(arguments[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
parser::Predicate predicate = parser::parse(queryString);
|
|
||||||
query_builder::ArgumentConverter<JSValueRef, JSContextRef> arguments(ctx, args);
|
|
||||||
Query query = results->get_query();
|
Query query = results->get_query();
|
||||||
query_builder::apply_predicate(query, predicate, arguments, *sharedRealm->config().schema,
|
return RJSResultsCreate(ctx, sharedRealm, results->get_object_schema(), query, argumentCount, arguments);
|
||||||
results->get_object_schema().name);
|
|
||||||
|
|
||||||
return RJSResultsCreate(ctx, sharedRealm, results->get_object_schema(), query);
|
|
||||||
}
|
}
|
||||||
catch (std::exception &exp) {
|
catch (std::exception &exp) {
|
||||||
if (jsException) {
|
if (jsException) {
|
||||||
|
@ -171,6 +160,21 @@ JSObjectRef RJSResultsCreate(JSContextRef ctx, SharedRealm realm, std::string cl
|
||||||
return RJSWrapObject<Results *>(ctx, RJSResultsClass(), new Results(realm, *object_schema, std::move(query)));
|
return RJSWrapObject<Results *>(ctx, RJSResultsClass(), new Results(realm, *object_schema, std::move(query)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JSObjectRef RJSResultsCreate(JSContextRef ctx, realm::SharedRealm realm, const realm::ObjectSchema &objectSchema, realm::Query &query, size_t argumentCount, const JSValueRef arguments[]) {
|
||||||
|
std::string queryString = RJSValidatedStringForValue(ctx, arguments[0], "predicate");
|
||||||
|
std::vector<JSValueRef> args(argumentCount-1);
|
||||||
|
for (size_t i = 1; i < argumentCount; i++) {
|
||||||
|
args[i-1] = arguments[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
parser::Predicate predicate = parser::parse(queryString);
|
||||||
|
query_builder::ArgumentConverter<JSValueRef, JSContextRef> queryArgs(ctx, args);
|
||||||
|
query_builder::apply_predicate(query, predicate, queryArgs, *realm->config().schema,
|
||||||
|
objectSchema.name);
|
||||||
|
|
||||||
|
return RJSResultsCreate(ctx, realm, objectSchema, query);
|
||||||
|
}
|
||||||
|
|
||||||
JSObjectRef RJSResultsCreate(JSContextRef ctx, SharedRealm realm, const ObjectSchema &objectSchema, const Query &query, bool live) {
|
JSObjectRef RJSResultsCreate(JSContextRef ctx, SharedRealm realm, const ObjectSchema &objectSchema, const Query &query, bool live) {
|
||||||
Results *results = new Results(realm, objectSchema, query);
|
Results *results = new Results(realm, objectSchema, query);
|
||||||
results->set_live(live);
|
results->set_live(live);
|
||||||
|
|
|
@ -16,4 +16,6 @@ namespace realm {
|
||||||
JSClassRef RJSResultsClass();
|
JSClassRef RJSResultsClass();
|
||||||
JSObjectRef RJSResultsCreate(JSContextRef ctx, realm::SharedRealm realm, std::string className);
|
JSObjectRef RJSResultsCreate(JSContextRef ctx, realm::SharedRealm realm, std::string className);
|
||||||
JSObjectRef RJSResultsCreate(JSContextRef ctx, realm::SharedRealm realm, std::string className, std::string query, std::vector<JSValueRef> args);
|
JSObjectRef RJSResultsCreate(JSContextRef ctx, realm::SharedRealm realm, std::string className, std::string query, std::vector<JSValueRef> args);
|
||||||
|
JSObjectRef RJSResultsCreate(JSContextRef ctx, realm::SharedRealm realm, const realm::ObjectSchema &objectSchema, realm::Query &query, size_t argumentCount, const JSValueRef arguments[]);
|
||||||
JSObjectRef RJSResultsCreate(JSContextRef ctx, realm::SharedRealm realm, const realm::ObjectSchema &objectSchema, const realm::Query &query, bool live = true);
|
JSObjectRef RJSResultsCreate(JSContextRef ctx, realm::SharedRealm realm, const realm::ObjectSchema &objectSchema, const realm::Query &query, bool live = true);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue