Web Services

Documentation » U.S. URDB MongoDB Query

U.S. Utility Rate Database Direct MongoDB Query Form

The U.S. Utility Rate Database Direct MongoDB Query Form provides direct access to the U.S. Utility Rate Database's underlying MongoDB database for custom query capability. The general query format is described by documentation for the MongoDB find command, but with a few restrictions in the name of compatibility with the PHP Mongo driver and backward compatibility with previous versions of the USURDB:

  • Surround strings with "double-quotes only", not 'single-quotes'.
  • Always enclose search keys with double-quotes. So not just strings such as "surname", but also operators such as "$in" or "$gt".
  • Instead of the "_id" key, use "label".
  • The value for the label (_id) is a string, not an ObjectId.
  • Time objects appear as strings rather than MongoDate or MongoDB\BSON\UTCDateTime, with format "YYYY-MM-DDTHH:MM.SS.000Z", i.e. "2012-06-05T20:51:30.000Z".
  • Use "true" or "false" with quotes to specify boolean values, not integers, empty strings, etc..

You may experiment with query results by simply clicking Search without entering any changes in the form. This returns 10 results (the default limit) which may as well be arbitrarily selected from the entire set and arbitrarily ordered. This is comparable to a MongoDB query with no criteria and a limit of 10 results.

Form Fields

Field Required Value Description
Conditions No
Type: String

Comparable to the query param in a MongoDB find query, used to filter or restrict results.

Sort By No
Options: USURDB Rate fields

Field to use for ordering search results.

Descending No
Type: Boolean

If checked and a field is designated in Sort By, results will be ordered in descending fashion. Default false (Ascending).

Distinct No
Options: USURDB Rate fields

Finds the distinct values for the specified field.

Offset No
Type: Integer

Skips the designated number of results, used to "page" through results, i.e. the Offset for every page would be incremented by one multiple of the Limit value.

Offset No
Type: Integer

Skips the designated number of results, used to "page" through results, i.e. the Offset for every page would be incremented by one multiple of the Limit value.

Limit No
Type: Integer

Maximum number of results to return. Default Limit is 10, maximum Limit is 500.

Count No
Type: Boolean

If checked, returns only the number of matching results.

Show Fields No
Type: Multi-Select

Use the Show Fields multi-select to restrict the rate fields to be returned.

Examples

  • Browse all rates, 1st "page" - Without updating any form fields (all text boxes empty, nothing selected in dropdowns except Format=json_plain, no checkboxes checked), click Search to see all database info on the first 10 rates (limit defaults to 10 if not set, max=500).
  • Browse the next 10 rates after the previous query - Set Offset to 10 and click Search.
  • Query database entry for the rate at https://apps.openei.org/USURDB/rate/view/5581e0e15457a39c656c88ab - Enter the following in the Conditions field:
    {"label":"5581e0e15457a39c656c88ab"}
  • Query rates for "Prairie Land Electric Coop Inc" utility - Enter the following in the Conditions field:
    {"utility":"Prairie Land Electric Coop Inc"}
  • Query for all rates edited by user with userid 2799 - Enter the following in the Conditions field:
    {"revisions.userid":2799}
  • Query for all rates edited by user with userid 2799 after 2015-03-26 - Enter the following in the Conditions field:
    {"revisions.userid":2799, "revisions.date":{"$gt":"2015-03-27T00:00:00.000Z"}}

See also the Utility Rate API.