using System.Collections.Generic;
using Microsoft.Azure.Documents;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Host;

namespace ChangeFeedFunction
{
    public static class RcModelFeed
    {
        [FunctionName("RcModelFeed")]
        public static void Run([CosmosDBTrigger("dojo", "rcmodel", ConnectionStringSetting = "AzureWebJobsDocumentDBConnectionString",
                LeaseCollectionName = "leases", LeaseDatabaseName = "dojo")]IReadOnlyList<Document> changeList, TraceWriter log)
        {
            if (changeList != null && changeList.Count > 0)
            {
                log.Verbose("Documents modified " + changeList.Count);
                var i = 0;

                foreach (var change in changeList)
                {
                    log.Verbose("document Id of $i: " + change.Id);
                    log.Verbose(change.ToString()); // Document全体を出力
                    i++;
                }
            }
        }
    }
}