WebFund 2015W: Assignment 5: Difference between revisions

From Soma-notes
No edit summary
No edit summary
Line 3: Line 3:
In this assignment you will create <tt>queryNotes.js</tt>, a program that will query the notes collection for matching notes.  Please submit your answers as a single JavaScript source file called "<username>-queryNotes.js" (where username is your MyCarletonOne username).  Please do not submit a zip file (i.e., no need for a node_modules directory).
In this assignment you will create <tt>queryNotes.js</tt>, a program that will query the notes collection for matching notes.  Please submit your answers as a single JavaScript source file called "<username>-queryNotes.js" (where username is your MyCarletonOne username).  Please do not submit a zip file (i.e., no need for a node_modules directory).


In addition to the points below, you also get up to 2 points for overall programming style.  In total, there are 10 points.  '''The questions below will be automatically graded for everything but style.'''
In total, there are 10 points.  '''The questions below will be automatically graded for everything but style.'''


This assignment is due March 2, 2015.
This assignment is due March 2, 2015.
Line 11: Line 11:
queryNotes.js should be called as follows:
queryNotes.js should be called as follows:


   node queryNotes.js [--output=<output file>] [--maxcount=<max number of documents to return>]  <query>  
   node queryNotes.js [--output=<output file>] [--maxcount=<max number of documents to return>]  <query> [<projection>]


Note the query is mandatory.  The output file should default to standard out, and the if no maxcount is specified then all matching documents should be returned.
Notes on the arguments:
* The query is mandatory.  It should be a single string that follows the syntax of a [http://docs.mongodb.org/manual/reference/method/db.collection.find/ find() criteria object] except that the enclosing curly braces are optional. 
* The output file should default to standard out.
* If no maxcount is specified then all matching documents should be returned.
* The projection should default to all fields.  The enclosing braces on the object should also be optional.


The query should be a single string that follows the syntax of a query object, except that the enclosing curly braces are optional.  In other words given this string you should be able to:
To be specific, to process the query and projection strings you should:
* add enclosing curly braces if they are not present,
* add enclosing curly braces if they are not present,
* convert the string to an object using [https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse JSON.parse()], and then  
* convert the string to an object using [https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/parse JSON.parse()], and then  
* retrieve all the documents using [http://docs.mongodb.org/manual/reference/method/db.collection.find/ queries given to find()] (getting a cursor object) and [http://docs.mongodb.org/manual/reference/method/cursor.toArray/ .toArray()] to actually get all the results returned in an array.
* create a cursor object using [http://docs.mongodb.org/manual/reference/method/db.collection.find/ find()], giving it the supplied criteria and optionally the projection object, and
* retrieve all of the objects using [http://docs.mongodb.org/manual/reference/method/cursor.toArray/ .toArray()] on the cursor object.
 
Points will be awarded as follows:
* ?
* ?
* ?
* 2 points for style

Revision as of 19:32, 24 February 2015

This Assignment is not yet finalized

In this assignment you will create queryNotes.js, a program that will query the notes collection for matching notes. Please submit your answers as a single JavaScript source file called "<username>-queryNotes.js" (where username is your MyCarletonOne username). Please do not submit a zip file (i.e., no need for a node_modules directory).

In total, there are 10 points. The questions below will be automatically graded for everything but style.

This assignment is due March 2, 2015.

Features

queryNotes.js should be called as follows:

 node queryNotes.js [--output=<output file>] [--maxcount=<max number of documents to return>]  <query> [<projection>]

Notes on the arguments:

  • The query is mandatory. It should be a single string that follows the syntax of a find() criteria object except that the enclosing curly braces are optional.
  • The output file should default to standard out.
  • If no maxcount is specified then all matching documents should be returned.
  • The projection should default to all fields. The enclosing braces on the object should also be optional.

To be specific, to process the query and projection strings you should:

  • add enclosing curly braces if they are not present,
  • convert the string to an object using JSON.parse(), and then
  • create a cursor object using find(), giving it the supplied criteria and optionally the projection object, and
  • retrieve all of the objects using .toArray() on the cursor object.

Points will be awarded as follows:

  • ?
  • ?
  • ?
  • 2 points for style