diff --git a/.docs/angular-meteor/client/scripts/routes.js b/.docs/angular-meteor/client/scripts/routes.js
index 21db548c8..74e4253e4 100644
--- a/.docs/angular-meteor/client/scripts/routes.js
+++ b/.docs/angular-meteor/client/scripts/routes.js
@@ -73,6 +73,10 @@ angular.module("meteor-angular-docs").config(['$urlRouterProvider', '$stateProvi
url: '/meteor-include',
template: UiRouter.template('api.meteor-include.html')
})
+ .state('api.collectionfs', {
+ url: '/collectionfs',
+ template: UiRouter.template('api.collectionfs.html')
+ })
.state('api.utils', {
url: '/utils',
template: UiRouter.template('api.utils.html')
diff --git a/.docs/angular-meteor/client/views/api.html b/.docs/angular-meteor/client/views/api.html
index 2a1e2f762..cb3beb333 100644
--- a/.docs/angular-meteor/client/views/api.html
+++ b/.docs/angular-meteor/client/views/api.html
@@ -13,6 +13,7 @@
User Authentication
$scope.getReactively
meteor-include directive
+ CollectionFS
$meteorUtils
$meteorCamera
$meteor.session.bind
diff --git a/.docs/angular-meteor/client/views/api/api.collectionfs.html b/.docs/angular-meteor/client/views/api/api.collectionfs.html
new file mode 100644
index 000000000..08f7cadb5
--- /dev/null
+++ b/.docs/angular-meteor/client/views/api/api.collectionfs.html
@@ -0,0 +1,37 @@
+
+
+
+ Improve this doc
+
+
+
+ {{#markdown}}
+
+# CollectionFS
+
+When working with CollectionFS we need to work differently with the `$meteor.collection` because
+collectionFS collection is a bit different than `Mongo.Collection`.
+
+To work with collectionFS we send a third argument to `$meteor.collection` which is the CollectionFS
+collection so that angular-meteor can use it to save and remove files.
+
+----
+
+## Usage
+
+ $meteorCollection(function() {
+ return Images.find();
+ }, false, Images);
+
+ // Or
+
+ $meteorCollection(Images, false);
+
+----
+
+ {{/markdown}}
+
+
+
+
diff --git a/.docs/angular-meteor/client/views/api/api.meteorCollection.html b/.docs/angular-meteor/client/views/api/api.meteorCollection.html
index b1f13006d..6382c6d85 100644
--- a/.docs/angular-meteor/client/views/api/api.meteorCollection.html
+++ b/.docs/angular-meteor/client/views/api/api.meteorCollection.html
@@ -52,6 +52,13 @@
No |
True |
+
+ | updateCollection |
+ Meteor Collection Object |
+ A collection object which will be used for updates (insert, update, delete). |
+ No |
+ |
+
diff --git a/.docs/angular-meteor/public/sitemap.xml b/.docs/angular-meteor/public/sitemap.xml
index b40321c5b..f07fbf6d5 100644
--- a/.docs/angular-meteor/public/sitemap.xml
+++ b/.docs/angular-meteor/public/sitemap.xml
@@ -125,4 +125,8 @@
http://angularjs.meteor.com/api/utils
0.5
+
+ http://angularjs.meteor.com/api/collectionfs
+ 0.5
+
diff --git a/modules/angular-meteor-meteorCollection.js b/modules/angular-meteor-meteorCollection.js
index 875ecf1e3..4fae67d0d 100644
--- a/modules/angular-meteor-meteorCollection.js
+++ b/modules/angular-meteor-meteorCollection.js
@@ -4,7 +4,7 @@ var angularMeteorCollections = angular.module('angular-meteor.meteor-collection'
['angular-meteor.subscribe', 'angular-meteor.utils', 'diffArray']);
-var AngularMeteorCollection = function (cursor, $q, $meteorSubscribe, $meteorUtils, $rootScope, $timeout) {
+var AngularMeteorCollection = function (cursor, collection, $q, $meteorSubscribe, $meteorUtils, $rootScope, $timeout) {
var self = [];
@@ -14,7 +14,7 @@ var AngularMeteorCollection = function (cursor, $q, $meteorSubscribe, $meteorUti
self.__proto__.$rootScope = $rootScope;
self.__proto__.$timeout = $timeout;
- self.$$collection = $meteorUtils.getCollectionByName(cursor.collection.name);
+ self.$$collection = angular.isDefined(collection) ? collection : $meteorUtils.getCollectionByName(cursor.collection.name);
return self;
};
@@ -41,8 +41,6 @@ AngularMeteorCollection.prototype.save = function save(docs, useUnsetModifier) {
function upsertObject(item, $q) {
var deferred = $q.defer();
- item = angular.copy(item);
-
if (item._id) { // Performs an update if the _id property is set.
var item_id = item._id; // Store the _id in temporary variable
delete item._id; // Remove the _id property so that it can be $set using update.
@@ -215,24 +213,26 @@ AngularMeteorCollection.prototype.stop = function () {
angularMeteorCollections.factory('$meteorCollection', ['$q', '$meteorSubscribe', '$meteorUtils', '$rootScope', '$timeout', 'diffArray',
function ($q, $meteorSubscribe, $meteorUtils, $rootScope, $timeout, diffArray) {
- return function (reactiveFunc, auto) {
+ return function (reactiveFunc, auto, collection) {
// Validate parameters
if (!reactiveFunc) {
throw new TypeError("The first argument of $meteorCollection is undefined.");
}
- if (!(typeof reactiveFunc == "function" || reactiveFunc instanceof Mongo.Collection)) {
- throw new TypeError("The first argument of $meteorCollection must be a function or a Mongo.Collection.");
+ if (!(typeof reactiveFunc == "function" || angular.isFunction(reactiveFunc.find))) {
+ throw new TypeError("The first argument of $meteorCollection must be a function or a have a find function property.");
}
auto = auto !== false;
- if (reactiveFunc instanceof Mongo.Collection) {
- var collection = reactiveFunc;
+ if (!(typeof reactiveFunc == "function")) {
+ var cursorFunc = reactiveFunc.find;
+ collection = angular.isDefined(collection) ? collection : reactiveFunc;
+ var originalCollection = reactiveFunc;
reactiveFunc = function() {
- return collection.find({});
+ return cursorFunc.apply(originalCollection, [{}]);
}
}
- var ngCollection = new AngularMeteorCollection(reactiveFunc(), $q, $meteorSubscribe, $meteorUtils, $rootScope, $timeout);
+ var ngCollection = new AngularMeteorCollection(reactiveFunc(), collection, $q, $meteorSubscribe, $meteorUtils, $rootScope, $timeout);
var realOldItems;
function setAutoBind() {