summaryrefslogtreecommitdiff
path: root/node_modules/mongoose/lib/collection.js
diff options
context:
space:
mode:
authorJules Laplace <jules@okfoc.us>2012-09-24 16:22:07 -0400
committerJules Laplace <jules@okfoc.us>2012-09-24 16:22:07 -0400
commit686106d544ecc3b6ffd4db2b665d3bc879a58d8c (patch)
treea5b5e50237cef70e12f0745371896e96f5f6d578 /node_modules/mongoose/lib/collection.js
ok
Diffstat (limited to 'node_modules/mongoose/lib/collection.js')
-rw-r--r--node_modules/mongoose/lib/collection.js167
1 files changed, 167 insertions, 0 deletions
diff --git a/node_modules/mongoose/lib/collection.js b/node_modules/mongoose/lib/collection.js
new file mode 100644
index 0000000..c4d5e79
--- /dev/null
+++ b/node_modules/mongoose/lib/collection.js
@@ -0,0 +1,167 @@
+
+/**
+ * Collection constructor
+ *
+ * @param {String} collection name
+ * @param {Collection} connection object
+ * @api public
+ */
+
+function Collection (name, conn) {
+ this.name = name;
+ this.conn = conn;
+ this.buffer = true;
+ this.queue = [];
+ if (this.conn.readyState == 1) this.onOpen();
+};
+
+/**
+ * The collection name
+ *
+ * @api public
+ */
+
+Collection.prototype.name;
+
+/**
+ * The Connection instance
+ *
+ * @api public
+ */
+
+Collection.prototype.conn;
+
+/**
+ * Called when the database connects
+ *
+ * @api private
+ */
+
+Collection.prototype.onOpen = function () {
+ var self = this;
+ this.buffer = false;
+ self.doQueue();
+};
+
+/**
+ * Called when the database disconnects
+ *
+ * @api private
+ */
+
+Collection.prototype.onClose = function () {
+ this.buffer = true;
+};
+
+/**
+ * Adds a callback to the queue
+ *
+ * @param {String} method name
+ * @param {Array} arguments
+ * @api private
+ */
+
+Collection.prototype.addQueue = function (name, args) {
+ this.queue.push([name, args]);
+ return this;
+};
+
+/**
+ * Executes the current queue
+ *
+ * @api private
+ */
+
+Collection.prototype.doQueue = function () {
+ for (var i = 0, l = this.queue.length; i < l; i++){
+ this[this.queue[i][0]].apply(this, this.queue[i][1]);
+ }
+ this.queue = [];
+ return this;
+};
+
+/**
+ * Ensure index function
+ *
+ * @api private
+ */
+
+Collection.prototype.ensureIndex = function(){
+ throw new Error('Collection#ensureIndex unimplemented by driver');
+};
+
+/**
+ * FindAndModify command
+ *
+ * @api private
+ */
+
+Collection.prototype.findAndModify = function(){
+ throw new Error('Collection#findAndModify unimplemented by driver');
+};
+
+/**
+ * FindOne command
+ *
+ * @api private
+ */
+
+Collection.prototype.findOne = function(){
+ throw new Error('Collection#findOne unimplemented by driver');
+};
+
+/**
+ * Find command
+ *
+ * @api private
+ */
+
+Collection.prototype.find = function(){
+ throw new Error('Collection#find unimplemented by driver');
+};
+
+/**
+ * Insert command
+ *
+ * @api private
+ */
+
+Collection.prototype.insert = function(){
+ throw new Error('Collection#insert unimplemented by driver');
+};
+
+/**
+ * Update command
+ *
+ * @api private
+ */
+
+Collection.prototype.save = function(){
+ throw new Error('Collection#save unimplemented by driver');
+};
+
+/**
+ * Insert command
+ *
+ * @api private
+ */
+
+Collection.prototype.update = function(){
+ throw new Error('Collection#update unimplemented by driver');
+};
+
+/**
+ * getIndexes command
+ *
+ * @api private
+ */
+
+Collection.prototype.getIndexes = function(){
+ throw new Error('Collection#getIndexes unimplemented by driver');
+};
+
+/**
+ * Module exports.
+ */
+
+module.exports = Collection;