Skip to content

Commit 1d42374

Browse files
committed
Added support for element operator
1 parent ee328ca commit 1d42374

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

MLAPI.ServerList.Server/Program.cs

+18
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,16 @@ private static bool FilterLocalServers(List<JToken> tokens, ServerModel serverMo
6767
return children.AsParallel().Any(x => FilterLocalServers(new List<JToken>() { x }, serverModel));
6868
}
6969
}
70+
break;
71+
case "$exists":
72+
{
73+
if (child.Type == JTokenType.Property)
74+
{
75+
string propertyName = ((JProperty)child.Parent.Parent).Name;
76+
77+
return serverModel.ContractData.ContainsKey(propertyName);
78+
}
79+
}
7080
break;
7181
case "$eq":
7282
{
@@ -314,6 +324,14 @@ private static FilterDefinition<ServerModel> CreateFilter(List<JToken> tokens)
314324
}
315325
}
316326
break;
327+
case "$exists":
328+
{
329+
if (child.Type == JTokenType.Property)
330+
{
331+
return Builders<ServerModel>.Filter.Exists("ContractData." + ((JProperty)child.Parent.Parent).Name);
332+
}
333+
}
334+
break;
317335
case "$eq":
318336
{
319337
if (child.Type == JTokenType.Property)

0 commit comments

Comments
 (0)