Skip to content

Commit

Permalink
fixes tabs in docstring
Browse files Browse the repository at this point in the history
  • Loading branch information
antiboredom committed Oct 18, 2014
1 parent 1c345f1 commit c097183
Showing 1 changed file with 55 additions and 50 deletions.
105 changes: 55 additions & 50 deletions lib/db.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/**
* A set of functions for dealing with data storage
*
* @class serviDB
*/
function serviDB(db) {
this.db = db;
}
Expand All @@ -9,8 +14,8 @@ function serviDB(db) {
* @param {object} object - the record to insert
* @param {function} [callback] - a callback function to execute after the insert completes
* @example
var books = serviapp.useDatabase('booksdb');
books.insert({title: 'The Trial', author: 'Franz Kafka'});
var books = serviapp.useDatabase('booksdb');
books.insert({title: 'The Trial', author: 'Franz Kafka'});
*/
serviDB.prototype.insert = function(params, cb) {
if (typeof cb === 'function') {
Expand All @@ -28,11 +33,11 @@ serviDB.prototype.insert = function(params, cb) {
* @param {function} callback - a callback function to execute after the search completes
* @example
var books = serviapp.useDatabase('booksdb');
books.find({author: 'Franz Kafka'}, function(err, results){
for (var i = 0; i < results.length; i++) {
console.log(results[i]._id, results[i].title, results[i].author);
}
});
books.find({author: 'Franz Kafka'}, function(err, results){
for (var i = 0; i < results.length; i++) {
console.log(results[i]._id, results[i].title, results[i].author);
}
});
*/
serviDB.prototype.find = function(params, cb) {
if (typeof cb === 'function') {
Expand All @@ -49,10 +54,10 @@ serviDB.prototype.find = function(params, cb) {
* @param {object} searchParameters - an object containing the search parameters
* @param {function} callback - a callback function to execute after the search completes
* @example
var books = serviapp.useDatabase('booksdb');
books.findOne({author: 'Franz Kafka'}, function(err, result){
console.log(results._id, results.title, results.author);
});
var books = serviapp.useDatabase('booksdb');
books.findOne({author: 'Franz Kafka'}, function(err, result){
console.log(results._id, results.title, results.author);
});
*/
serviDB.prototype.findOne = function(params, cb) {
if (typeof cb === 'function') {
Expand Down Expand Up @@ -89,10 +94,10 @@ serviDB.prototype.removeIndex = function(params, cb) {
* @param {string} id - the id of the record to retrieve
* @param {function} callback - a callback function to execute with the record
* @example
var books = serviapp.useDatabase('booksdb');
books.getOne("some_id_here", function(result){
console.log(result._id, result.title, result.author);
});
var books = serviapp.useDatabase('booksdb');
books.getOne("some_id_here", function(result){
console.log(result._id, result.title, result.author);
});
*/
serviDB.prototype.getOne = function(id, cb) {
if (typeof cb === 'function') {
Expand All @@ -113,30 +118,30 @@ serviDB.prototype.getOne = function(id, cb) {
* @param {integer} [limit] - optionally limit how many records to retreive
* @param {integer} [skip] - optionally skip a number of records
* @example
var books = serviapp.useDatabase('booksdb');
books.getAll(function(results){
console.log(results);
});
// sort by author's name in ascending order
books.getAll({author: 1}, function(results){
console.log(results);
});
// sort by author's name in descending order
books.getAll({author: -1}, function(results){
console.log(results);
});
// limit the results to 10
books.getAll(10, function(results){
console.log(results);
});
// limit the results to 10 and start at the 20th result
books.getAll(20, 10, function(results){
console.log(results);
});
var books = serviapp.useDatabase('booksdb');
books.getAll(function(results){
console.log(results);
});
// sort by author's name in ascending order
books.getAll({author: 1}, function(results){
console.log(results);
});
// sort by author's name in descending order
books.getAll({author: -1}, function(results){
console.log(results);
});
// limit the results to 10
books.getAll(10, function(results){
console.log(results);
});
// limit the results to 10 and start at the 20th result
books.getAll(20, 10, function(results){
console.log(results);
});
*/
serviDB.prototype.getAll = function() {
var cb, sort, skip, limit = null;
Expand Down Expand Up @@ -179,12 +184,12 @@ serviDB.prototype.getAll = function() {
* @param {object} value - the value of of the key to search for
* @param {function} callback - the callback function to execute with the retrieved records
* @example
var books = serviapp.useDatabase('booksdb');
var books = serviapp.useDatabase('booksdb');
// find all books writen by Kafka
books.search('author', 'Kafka', function(results){
console.log(results);
});
// find all books writen by Kafka
books.search('author', 'Kafka', function(results){
console.log(results);
});
*/

serviDB.prototype.search = function(key, val, cb) {
Expand All @@ -205,8 +210,8 @@ serviDB.prototype.search = function(key, val, cb) {
* @method add
* @param {object} object - the record to insert
* @example
var books = serviapp.useDatabase('booksdb');
books.insert({title: 'The Man Without Qualities', author: 'Robert Musil'});
var books = serviapp.useDatabase('booksdb');
books.insert({title: 'The Man Without Qualities', author: 'Robert Musil'});
*/
serviDB.prototype.add = function(doc) {
this.insert(doc);
Expand All @@ -218,8 +223,8 @@ serviDB.prototype.add = function(doc) {
* @method delete
* @param {integer} id - the id of the record to delete
* @example
var books = serviapp.useDatabase('booksdb');
books.delete(id);
var books = serviapp.useDatabase('booksdb');
books.delete(id);
*/
serviDB.prototype.delete = function(id) {
this.remove({'_id': id});
Expand All @@ -232,8 +237,8 @@ serviDB.prototype.delete = function(id) {
* @param {integer} id - the id of the record to change
* @param {object} fields - an object containing the fields to change
* @example
var books = serviapp.useDatabase('booksdb');
books.change(id, {pages: 100});
var books = serviapp.useDatabase('booksdb');
books.change(id, {pages: 100});
*/
serviDB.prototype.change = function(id, fields) {
this.update({'_id': id}, {$set: fields});
Expand Down

0 comments on commit c097183

Please sign in to comment.