Skip to content

Commit b5338aa

Browse files
committed
DocDb: removing cardinality requirement
1 parent fc8557c commit b5338aa

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

src/WebJobs.Script/Binding/DocumentDBScriptBindingProvider.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,18 +68,20 @@ public DocumentDBScriptBinding(ScriptBindingContext context) : base(context)
6868
{
6969
}
7070

71+
private string Id => Context.GetMetadataValue<string>("id");
72+
7173
public override Type DefaultType
7274
{
7375
get
7476
{
7577
if (Context.Access == FileAccess.Read)
7678
{
77-
if (Context.Cardinality == "many")
79+
if (Id != null)
7880
{
79-
return typeof(JArray);
81+
return typeof(JObject);
8082
}
8183

82-
return typeof(JObject);
84+
return typeof(JArray);
8385
}
8486
else
8587
{
@@ -107,7 +109,7 @@ public override Collection<Attribute> GetAttributes()
107109

108110
attribute.CreateIfNotExists = Context.GetMetadataValue<bool>("createIfNotExists");
109111
attribute.ConnectionStringSetting = Context.GetMetadataValue<string>("connection");
110-
attribute.Id = Context.GetMetadataValue<string>("id");
112+
attribute.Id = Id;
111113
attribute.PartitionKey = Context.GetMetadataValue<string>("partitionKey");
112114
attribute.CollectionThroughput = Context.GetMetadataValue<int>("collectionThroughput");
113115
attribute.SqlQuery = Context.GetMetadataValue<string>("sqlQuery");

test/WebJobs.Script.Tests.Integration/TestScripts/Node/DocumentDBIn/function.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@
2020
"direction": "in",
2121
"databaseName": "ItemDb",
2222
"collectionName": "ItemCollection",
23-
"sqlQuery": "SELECT f.id, f.related FROM f WHERE f.related = {documentId}",
24-
"cardinality": "many"
23+
"sqlQuery": "SELECT f.id, f.related FROM f WHERE f.related = {documentId}"
2524
},
2625
{
2726
"type": "documentDB",

0 commit comments

Comments
 (0)