public RavenJArray UpdateByIndex(string indexName, IndexQuery queryToUpdate, PatchRequest[] patchRequests, BulkOperationOptions options = null)
 {
     return PerformBulkOperation(indexName, queryToUpdate, options, (docId, tx) =>
     {
         var patchResult = database.Patches.ApplyPatch(docId, null, patchRequests, tx);
         return new { Document = docId, Result = patchResult };
     });
 }
        public void Add_New_Tag_To_Employee_Without_Loading_The_Document()
        {
            var pr = new PatchRequest
            {
                Type = PatchCommandType.Add,
                Name = "Tags",
                Value = "Hotbot"
            };

            Store.DatabaseCommands.Patch("employees/10", new[] {pr});
        }
        /// <summary>
        /// Sends a patch request for a specific document, ignoring the document's Etag
        /// </summary>
        /// <param name="key">Id of the document to patch</param>
        /// <param name="patches">Array of patch requests</param>
        /// <param name="commands">The low level database commands interface.</param>
        public static Task PatchAsync(this IAsyncDatabaseCommands commands, string key, PatchRequest[] patches)
		{
			return commands.PatchAsync(key, patches, null);
		}
Beispiel #4
0
        //[Fact]
        public void FixNamespacesForDocuments()
        {
            var documentStore = new DocumentStore()
            {
                ConnectionStringName = "Secure",
                Conventions =
                {
                    DefaultQueryingConsistency = ConsistencyOptions.QueryYourWrites,
                    FindTypeTagName = type =>
                    {
                        if (typeof(Initiative).IsAssignableFrom(type))
                            return "Initiatives";
                        return DocumentConvention.DefaultTypeTagName(type);
                    }
                },
                
            };
            documentStore.Initialize();
            var documentSession = documentStore.OpenSession();

            var task = documentStore.AsyncDatabaseCommands.GetDocumentsAsync(0, 10000);

            task.Wait();

            var documents = task.Result;

            foreach (var document in documents)
            {
                var ravenClrType = document.Metadata["Raven-Clr-Type"];
                if (ravenClrType == null)
                    continue;
                var value = ravenClrType.ToString();
                if (!value.Contains("SkazhiKazinoNet."))
                    return;
                value = value.Replace("SkazhiKazinoNet.", "CivilDoIt.");

                var patchRequest = new PatchRequest()
                                       {
                                           Type = PatchCommandType.Modify,
                                           Name = "@metadata",
                                           Nested = new[]
                                                        {
                                                            new PatchRequest
                                                                {
                                                                    Name = "Raven-Clr-Type",
                                                                    Type = PatchCommandType.Set,
                                                                    Value = value
                                                                }
                                                        }
                                       };

                documentStore.DatabaseCommands.Patch(document.Key, new [] { patchRequest });
            }
        }