Skip to content

Commit 8c86c17

Browse files
committed
Merge pull request Azure#48 from arramac/master
Fix comments
2 parents 7c5aa98 + da6cde1 commit 8c86c17

File tree

1 file changed

+14
-30
lines changed

1 file changed

+14
-30
lines changed

samples/code-samples/Queries.JavaScript/Program.cs

Lines changed: 14 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
namespace DocumentDB.Samples.Queries.Spatial
1+
namespace DocumentDB.Samples.Queries.JavaScript
22
{
33
using System;
44
using System.Collections.Generic;
@@ -15,10 +15,7 @@
1515
using Newtonsoft.Json.Serialization;
1616

1717
/// <summary>
18-
/// This sample demonstrates the use of geospatial indexing and querying with Azure DocumentDB. We
19-
/// look at how to store Points using the classes in the Microsoft.Azure.Documents.Spatial namespace,
20-
/// how to enable a collection for geospatial indexing, and how to query for WITHIN and DISTANCE
21-
/// using SQL and LINQ.
18+
/// This sample demonstrates the use of JavaScript language integrated queries with Azure DocumentDB.
2219
/// </summary>
2320
public class Program
2421
{
@@ -42,26 +39,6 @@ public class Program
4239
/// </summary>
4340
private static readonly string AuthorizationKey = ConfigurationManager.AppSettings["AuthorizationKey"];
4441

45-
/// <summary>
46-
/// Gets an indexing policy with spatial enabled. You can also configure just certain paths for spatial indexing, e.g. Path = "/location/?"
47-
/// </summary>
48-
private static readonly IndexingPolicy IndexingPolicyWithSpatialEnabled = new IndexingPolicy
49-
{
50-
IncludedPaths = new System.Collections.ObjectModel.Collection<IncludedPath>()
51-
{
52-
new IncludedPath
53-
{
54-
Path = "/*",
55-
Indexes = new System.Collections.ObjectModel.Collection<Index>()
56-
{
57-
new SpatialIndex(DataType.Point),
58-
new RangeIndex(DataType.Number) { Precision = -1 },
59-
new RangeIndex(DataType.String) { Precision = -1 }
60-
}
61-
}
62-
}
63-
};
64-
6542
/// <summary>
6643
/// Gets the client to use.
6744
/// </summary>
@@ -99,7 +76,7 @@ public static void Main(string[] args)
9976
}
10077

10178
/// <summary>
102-
/// Run the geospatial demo.
79+
/// Run the JavaScript language integrated queries samples.
10380
/// </summary>
10481
/// <param name="databaseId">The database Id.</param>
10582
/// <param name="collectionId">The collection Id.</param>
@@ -130,7 +107,8 @@ private static async Task RunDemoAsync(string databaseId, string collectionId)
130107
Console.WriteLine("Projection query returned: {0}", JsonConvert.SerializeObject(projectionQueryResult, Formatting.Indented));
131108

132109
// Run a query using filter and map (using chaining)
133-
object chainQueryResult = await QueryScalar(collection.SelfLink,
110+
object chainQueryResult = await QueryScalar(
111+
collection.SelfLink,
134112
@"__.chain()
135113
.filter(function(person) { return person.firstName === 'Andrew'; })
136114
.map(function(person) { return { familyName: person.lastName, address: person.address }; })
@@ -139,7 +117,8 @@ private static async Task RunDemoAsync(string databaseId, string collectionId)
139117
Console.WriteLine("Chain (filter & projection) query returned: {0}", JsonConvert.SerializeObject(chainQueryResult, Formatting.Indented));
140118

141119
// Run a chained filter, map and sorting (using chaining)
142-
object sortQueryResult = await QueryScalar(collection.SelfLink,
120+
object sortQueryResult = await QueryScalar(
121+
collection.SelfLink,
143122
@"__.chain()
144123
.filter(function(person) { return person.firstName === 'Andrew' || person.firstName === 'Ryan'; })
145124
.sortBy(function(person) { return person.lastName; })
@@ -205,9 +184,13 @@ private static async Task<DocumentCollection> GetCollection(string databaseLink,
205184
/// Run a query that returns a single document, and display it
206185
/// </summary>
207186
/// <param name="collectionLink">The collection self-link</param>
208-
/// <param name="query">The query to run</param>
187+
/// <param name="javascriptQuery">The query to run</param>
188+
/// <returns>The result of the query as an object.</returns>
209189
private static async Task<object> QueryScalar(string collectionLink, string javascriptQuery)
210190
{
191+
// JavaScript integrated queries are supported using the server side SDK, so you'll be using
192+
// them within stored procedures and triggers. Here we show them standalone just to demonstrate
193+
// how to use the functional-Underscore.js style query API
211194
string javaScriptFunctionStub = string.Format("function() {{ {0}; }}", javascriptQuery);
212195
string singleQuerySprocName = "query";
213196

@@ -240,7 +223,8 @@ private static async Task<object> QueryScalar(string collectionLink, string java
240223
/// Create a document from JSON string
241224
/// </summary>
242225
/// <param name="collectionLink">The collection self-link</param>
243-
/// <param name="query">The JSON to create</param>
226+
/// <param name="json">The JSON to create</param>
227+
/// <returns>The Task for asynchronous execution.</returns>
244228
private static async Task CreateDocumentAsync(string collectionLink, string json)
245229
{
246230
using (System.IO.MemoryStream ms = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(json)))

0 commit comments

Comments
 (0)