Example #1
0
        public void Execute(LiteEngine db, StringScanner s, Display display)
        {
            var col   = this.ReadCollection(db, s);
            var query = s.Match("{") ? Query.All() : this.ReadQuery(s);
            var code  = DynamicCode.GetCode(s);

            var docs = col.Find(query).ToArray();

            try
            {
                db.BeginTrans();

                foreach (var doc in docs)
                {
                    code(doc["_id"].RawValue, doc, col, db);
                }

                db.Commit();

                display.WriteBson(docs.Length);
            }
            catch (Exception ex)
            {
                db.Rollback();
                throw ex;
            }
        }
Example #2
0
        public BsonValue Execute(LiteDatabase db, StringScanner s)
        {
            var col   = this.ReadCollection(db, s);
            var query = s.Match("{") ? Query.All() : this.ReadQuery(s);
            var code  = DynamicCode.GetCode(s);

            var docs = col.Find(query).ToArray();

            try
            {
                db.BeginTrans();

                foreach (var doc in docs)
                {
                    code(doc["_id"], doc, col, db);
                }

                db.Commit();

                return(docs.Length);
            }
            catch (Exception ex)
            {
                db.Rollback();
                throw ex;
            }
        }