mirror of https://gitee.com/bigwinds/arangodb
returnNew and returnOld, progress.
This commit is contained in:
parent
968d1cfd1f
commit
1c94f8d1be
|
@ -1103,7 +1103,7 @@ OperationResult Transaction::modifyLocal(
|
|||
}
|
||||
TRI_doc_mptr_t mptr;
|
||||
VPackSlice actualRevision;
|
||||
TRI_doc_mptr_t* previous = nullptr;
|
||||
TRI_doc_mptr_t previous;
|
||||
|
||||
if (operation == TRI_VOC_DOCUMENT_OPERATION_REPLACE) {
|
||||
res = document->replace(this, newVal, &mptr, options,
|
||||
|
@ -1120,7 +1120,7 @@ OperationResult Transaction::modifyLocal(
|
|||
std::string key = newVal.get(TRI_VOC_ATTRIBUTE_KEY).copyString();
|
||||
buildDocumentIdentity(resultBuilder, cid, key, actualRevision,
|
||||
VPackSlice(),
|
||||
options.returnOld ? previous : nullptr, nullptr);
|
||||
options.returnOld ? &previous : nullptr, nullptr);
|
||||
return TRI_ERROR_ARANGO_CONFLICT;
|
||||
} else if (res != TRI_ERROR_NO_ERROR) {
|
||||
return res;
|
||||
|
@ -1132,7 +1132,7 @@ OperationResult Transaction::modifyLocal(
|
|||
std::string key = newVal.get(TRI_VOC_ATTRIBUTE_KEY).copyString();
|
||||
buildDocumentIdentity(resultBuilder, cid, key,
|
||||
mptr.revisionIdAsSlice(), actualRevision,
|
||||
options.returnOld ? previous : nullptr ,
|
||||
options.returnOld ? &previous : nullptr ,
|
||||
options.returnNew ? &mptr : nullptr);
|
||||
}
|
||||
return TRI_ERROR_NO_ERROR;
|
||||
|
|
|
@ -553,10 +553,8 @@ static void DocumentVocbase(
|
|||
TRI_V8_THROW_EXCEPTION(res);
|
||||
}
|
||||
|
||||
VPackOptions resultOptions = VPackOptions::Defaults;
|
||||
resultOptions.customTypeHandler = opResult.customTypeHandler.get();
|
||||
|
||||
v8::Handle<v8::Value> result = TRI_VPackToV8(isolate, opResult.slice(), &resultOptions);
|
||||
v8::Handle<v8::Value> result = TRI_VPackToV8(isolate, opResult.slice(),
|
||||
transactionContext->getVPackOptions());
|
||||
|
||||
TRI_V8_RETURN(result);
|
||||
}
|
||||
|
@ -703,6 +701,14 @@ static void RemoveVocbase(v8::FunctionCallbackInfo<v8::Value> const& args) {
|
|||
options.waitForSync =
|
||||
TRI_ObjectToBoolean(optionsObject->Get(WaitForSyncKey));
|
||||
}
|
||||
TRI_GET_GLOBAL_STRING(ReturnNewKey);
|
||||
if (optionsObject->Has(ReturnNewKey)) {
|
||||
options.returnNew = TRI_ObjectToBoolean(optionsObject->Get(ReturnNewKey));
|
||||
}
|
||||
TRI_GET_GLOBAL_STRING(ReturnOldKey);
|
||||
if (optionsObject->Has(ReturnOldKey)) {
|
||||
options.returnOld = TRI_ObjectToBoolean(optionsObject->Get(ReturnOldKey));
|
||||
}
|
||||
} else { // old variant replace(<document>, <data>, <overwrite>,
|
||||
// <waitForSync>)
|
||||
options.ignoreRevs = TRI_ObjectToBoolean(args[1]);
|
||||
|
@ -1546,6 +1552,14 @@ static void parseReplaceAndUpdateOptions(
|
|||
if (optionsObject->Has(SilentKey)) {
|
||||
options.silent = TRI_ObjectToBoolean(optionsObject->Get(SilentKey));
|
||||
}
|
||||
TRI_GET_GLOBAL_STRING(ReturnNewKey);
|
||||
if (optionsObject->Has(ReturnNewKey)) {
|
||||
options.returnNew = TRI_ObjectToBoolean(optionsObject->Get(ReturnNewKey));
|
||||
}
|
||||
TRI_GET_GLOBAL_STRING(ReturnOldKey);
|
||||
if (optionsObject->Has(ReturnOldKey)) {
|
||||
options.returnOld = TRI_ObjectToBoolean(optionsObject->Get(ReturnOldKey));
|
||||
}
|
||||
if (operation == TRI_VOC_DOCUMENT_OPERATION_UPDATE) {
|
||||
// intentionally not called for TRI_VOC_DOCUMENT_OPERATION_REPLACE
|
||||
TRI_GET_GLOBAL_STRING(KeepNullKey);
|
||||
|
@ -1716,7 +1730,8 @@ static void ModifyVocbaseCol(TRI_voc_document_operation_e operation,
|
|||
}
|
||||
|
||||
VPackSlice resultSlice = opResult.slice();
|
||||
TRI_V8_RETURN(TRI_VPackToV8(isolate, resultSlice));
|
||||
TRI_V8_RETURN(TRI_VPackToV8(isolate, resultSlice,
|
||||
transactionContext->getVPackOptions()));
|
||||
TRI_V8_TRY_CATCH_END
|
||||
}
|
||||
|
||||
|
@ -1840,7 +1855,8 @@ static void ModifyVocbase(TRI_voc_document_operation_e operation,
|
|||
}
|
||||
|
||||
VPackSlice resultSlice = opResult.slice();
|
||||
TRI_V8_RETURN(TRI_VPackToV8(isolate, resultSlice));
|
||||
TRI_V8_RETURN(TRI_VPackToV8(isolate, resultSlice,
|
||||
transactionContext->getVPackOptions()));
|
||||
TRI_V8_TRY_CATCH_END
|
||||
}
|
||||
|
||||
|
@ -2041,8 +2057,9 @@ static void JS_SaveVocbase(v8::FunctionCallbackInfo<v8::Value> const& args) {
|
|||
}
|
||||
|
||||
// load collection
|
||||
SingleCollectionTransaction trx(V8TransactionContext::Create(vocbase, true),
|
||||
collectionName, TRI_TRANSACTION_WRITE);
|
||||
auto transactionContext(V8TransactionContext::Create(vocbase, true));
|
||||
SingleCollectionTransaction trx(transactionContext,
|
||||
collectionName, TRI_TRANSACTION_WRITE);
|
||||
trx.addHint(TRI_TRANSACTION_HINT_SINGLE_OPERATION, false);
|
||||
|
||||
res = trx.begin();
|
||||
|
@ -2061,7 +2078,8 @@ static void JS_SaveVocbase(v8::FunctionCallbackInfo<v8::Value> const& args) {
|
|||
|
||||
VPackSlice resultSlice = result.slice();
|
||||
|
||||
TRI_V8_RETURN(TRI_VPackToV8(isolate, resultSlice));
|
||||
TRI_V8_RETURN(TRI_VPackToV8(isolate, resultSlice,
|
||||
transactionContext->getVPackOptions()));
|
||||
TRI_V8_TRY_CATCH_END
|
||||
}
|
||||
|
||||
|
@ -2202,7 +2220,7 @@ static void JS_InsertVocbaseVPack(
|
|||
VPackSlice resultSlice = result.slice();
|
||||
|
||||
TRI_V8_RETURN(TRI_VPackToV8(isolate, resultSlice,
|
||||
transactionContext->getVPackOptions()));
|
||||
transactionContext->getVPackOptions()));
|
||||
TRI_V8_TRY_CATCH_END
|
||||
}
|
||||
|
||||
|
|
|
@ -3371,12 +3371,11 @@ int TRI_document_collection_t::update(Transaction* trx,
|
|||
OperationOptions& options,
|
||||
bool lock,
|
||||
VPackSlice& prevRev,
|
||||
TRI_doc_mptr_t*& previous) {
|
||||
TRI_doc_mptr_t& previous) {
|
||||
// initialize the result
|
||||
TRI_ASSERT(mptr != nullptr);
|
||||
mptr->setDataPtr(nullptr);
|
||||
prevRev = VPackSlice();
|
||||
previous = nullptr;
|
||||
|
||||
TRI_voc_rid_t revisionId = TRI_NewTickServer();
|
||||
|
||||
|
@ -3407,7 +3406,7 @@ int TRI_document_collection_t::update(Transaction* trx,
|
|||
}
|
||||
|
||||
prevRev = oldHeader->revisionIdAsSlice();
|
||||
previous = oldHeader;
|
||||
previous = *oldHeader;
|
||||
|
||||
// Check old revision:
|
||||
if (!options.ignoreRevs) {
|
||||
|
@ -3477,9 +3476,8 @@ int TRI_document_collection_t::replace(Transaction* trx,
|
|||
OperationOptions& options,
|
||||
bool lock,
|
||||
VPackSlice& prevRev,
|
||||
TRI_doc_mptr_t*& previous) {
|
||||
TRI_doc_mptr_t& previous) {
|
||||
prevRev = VPackSlice();
|
||||
previous = nullptr;
|
||||
|
||||
if (_info.type() == TRI_COL_TYPE_EDGE) {
|
||||
VPackSlice s = newSlice.get(TRI_VOC_ATTRIBUTE_FROM);
|
||||
|
@ -3525,7 +3523,7 @@ int TRI_document_collection_t::replace(Transaction* trx,
|
|||
}
|
||||
|
||||
prevRev = oldHeader->revisionIdAsSlice();
|
||||
previous = oldHeader;
|
||||
previous = *oldHeader;
|
||||
|
||||
// Check old revision:
|
||||
if (!options.ignoreRevs) {
|
||||
|
|
|
@ -219,10 +219,10 @@ struct TRI_document_collection_t : public TRI_collection_t {
|
|||
TRI_doc_mptr_t*, arangodb::OperationOptions&, bool);
|
||||
int update(arangodb::Transaction*, arangodb::velocypack::Slice const,
|
||||
TRI_doc_mptr_t*, arangodb::OperationOptions&, bool,
|
||||
VPackSlice&, TRI_doc_mptr_t*&);
|
||||
VPackSlice&, TRI_doc_mptr_t&);
|
||||
int replace(arangodb::Transaction*, arangodb::velocypack::Slice const,
|
||||
TRI_doc_mptr_t*, arangodb::OperationOptions&, bool,
|
||||
VPackSlice&, TRI_doc_mptr_t*&);
|
||||
VPackSlice&, TRI_doc_mptr_t&);
|
||||
int remove(arangodb::Transaction*, arangodb::velocypack::Slice const,
|
||||
arangodb::OperationOptions&, bool, VPackSlice&, TRI_doc_mptr_t*&);
|
||||
|
||||
|
|
Loading…
Reference in New Issue