Esempio n. 1
0
        /// <summary>
        /// Note:  Before/After Save does not get called with this method.
        /// Find and Update FIRST matching document
        /// </summary>
        /// <param name="query"></param>
        /// <param name="sort"></param>
        /// <param name="update"></param>
        /// <param name="returnNew"></param>
        /// <param name="upsert"></param>
        /// <returns></returns>
        public FindAndModifyResult FindAndUpdate(IMongoQuery query, IMongoSortBy sort, IMongoUpdate update, bool returnNew, bool upsert)
        {
            //Implement necessary logic here (e.g.  auditing)
            IMongoQuery fixedQuery = MongoUtil.FormatIdElementForMongoQuery(query);

            return(Collection.FindAndModify(fixedQuery, sort, update, returnNew, upsert));
        }
Esempio n. 2
0
        public WriteConcernResult Update(IMongoQuery query, UpdateBuilder update, UpdateFlags updateFlags, WriteConcern writeConcern)
        {
            //TODO:  paul, deal with auditing
            IMongoQuery fixedQuery = MongoUtil.FormatIdElementForMongoQuery(query);

            return(Collection.Update(query, update, updateFlags, writeConcern));
        }
Esempio n. 3
0
        public MongoCursor <T> Find(IMongoQuery query, params string[] propertiesToReturn)
        {
            IMongoQuery fixedQuery = MongoUtil.FormatIdElementForMongoQuery(query);
            var         cursor     = Collection.Find(fixedQuery);

            cursor.SetFields(propertiesToReturn);

            return(cursor);
        }
Esempio n. 4
0
        public IEnumerable <string> Distinct(string key, IMongoQuery query)
        {
            IMongoQuery fixedQuery = MongoUtil.FormatIdElementForMongoQuery(query);

            var results = Collection.Distinct(key, fixedQuery);

            return(results.Where(x => x != BsonNull.Value)
                   .Select(x => x.ToString()));
        }
Esempio n. 5
0
        public MongoCursor <Y> FindAs <Y>(IMongoQuery query)
        {
            IMongoQuery fixedQuery = MongoUtil.FormatIdElementForMongoQuery(query);

            return(Collection.FindAs <Y>(fixedQuery));
        }
Esempio n. 6
0
        public MongoCursor FindAsBsonDocument(IMongoQuery query)
        {
            IMongoQuery fixedQuery = MongoUtil.FormatIdElementForMongoQuery(query);

            return(Collection.FindAs <BsonDocument>(fixedQuery));
        }
Esempio n. 7
0
        /// <summary>
        /// Note:  Before/After delete do not get called with this method
        /// </summary>
        /// <param name="query"></param>
        /// <param name="writeConcern"></param>
        /// <returns></returns>
        public WriteConcernResult Remove(IMongoQuery query, WriteConcern writeConcern)
        {
            IMongoQuery fixedQuery = MongoUtil.FormatIdElementForMongoQuery(query);

            return(Collection.Remove(fixedQuery, writeConcern));
        }
Esempio n. 8
0
        public MapReduceResult MapReduce(IMongoQuery query, BsonJavaScript map, BsonJavaScript reduce, IMongoMapReduceOptions options)
        {
            IMongoQuery fixedQuery = MongoUtil.FormatIdElementForMongoQuery(query);

            return(Collection.MapReduce(fixedQuery, map, reduce, options));
        }
Esempio n. 9
0
        public IEnumerable <BsonDocument> Group(IMongoQuery query, string key, BsonDocument initial, BsonJavaScript reduce, BsonJavaScript finalize)
        {
            IMongoQuery fixedQuery = MongoUtil.FormatIdElementForMongoQuery(query);

            return(Collection.Group(fixedQuery, key, initial, reduce, finalize));
        }
Esempio n. 10
0
        public T FindOne(IMongoQuery query)
        {
            IMongoQuery fixedQuery = MongoUtil.FormatIdElementForMongoQuery(query);

            return(Collection.FindOne(fixedQuery));
        }
Esempio n. 11
0
        /// <summary>
        ////Find and remove the FIRST item found.
        /// Note:  Before and After Delete do not get called with this method.
        /// </summary>
        /// <param name="query"></param>
        /// <param name="sort"></param>
        /// <returns></returns>
        public FindAndModifyResult FindAndRemove(IMongoQuery query, IMongoSortBy sort)
        {
            IMongoQuery fixedQuery = MongoUtil.FormatIdElementForMongoQuery(query);

            return(Collection.FindAndRemove(fixedQuery, sort));
        }