Apply manipulators to an incoming SON object before it gets stored.

        :Parameters:
          - `son`: the son object going into the database
          - `collection`: the collection the son object is being saved in
489376
def _fix_incoming(self, son, collection):
        
        son = self._apply_incoming_manipulators(son, collection)
        son = self._apply_incoming_copying_manipulators(son, collection)
        return son
32665
def update_collection(self, collection):
        
        node = self.node
        flow = node if node.is_flow else node.flow

        # Build the key used to store the entry in the document.
        key = node.name
        if node.is_task:
            key = "w" + str(node.pos[0]) + "_t" + str(node.pos[1])
        elif node.is_work:
            key = "w" + str(node.pos)

        db = collection.database

        # Save files with GridFs first in order to get the ID.
        if self.gridfs_files:
            import gridfs
            fs = gridfs.GridFS(db)
            for ext, gridfile in self.gridfs_files.items():
                logger.info("gridfs: about to put file:", str(gridfile))
                # Here we set gridfile.fs_id that will be stored in the mondodb document
                try:
                    with open(gridfile.path, "r" + gridfile.mode) as f:
                        gridfile.fs_id = fs.put(f, filename=gridfile.path)
                except IOError as exc:
                    logger.critical(str(exc))

        if flow.mongo_id is None:
            # Flow does not have a mongo_id, allocate doc for the flow and save its id.
            flow.mongo_id = collection.insert({})
            print("Creating flow.mongo_id", flow.mongo_id, type(flow.mongo_id))

        # Get the document from flow.mongo_id and update it.
        doc = collection.find_one({"_id": flow.mongo_id})
        if key in doc:
            raise ValueError("%s is already in doc!" % key)
        doc[key] = self.as_dict()

        collection.save(doc)
252932
def outgoing_manipulators(self):
        
        warnings.warn("Database.outgoing_manipulators() is deprecated",
                      DeprecationWarning, stacklevel=2)

        return [manipulator.__class__.__name__
                for manipulator in self.__outgoing_manipulators]
38284
def update_many(self, **kwargs):
        
        db_objects = self.get_dbcollection_with_es(**kwargs)
        return self.Model._update_many(
            db_objects, self._json_params, self.request)
447925
function (soajs, combo, cb) {
        soajs.mongoDb.insert(combo.collection, combo.record, cb);
    }
172045
def add_collection(collection,
                   cache_size=1000,
                   cache_cls=LRUCache,
                   **cache_args):
    """"""
    assert collection not in _db
    cache = cache_cls(maxsize=cache_size,
                      missing=lambda id: load_object(collection, id),
                      **cache_args)
    _db[collection] = aadict(cache=cache, indexes={})
1346802
function(collection){
	Array.apply(this);
	if(arguments.length >= 1){
		for(var i=0,len = collection.length;i<len;i++){
			var item = collection[i];
			if(this.indexOf(item) < 0){
				this.push(item);
			}
		}
	}
 }
696210
def add(self, node):
        
        self.sons.append(node)
        node.parent = self
1121547
def transform_incoming(self, son, collection):
        """"""
        return self._transform_incoming(copy.deepcopy(son), collection)
945708
def init_relation(self, models, relation):
        
        for model in models:
            model.set_relation(
                relation, Result(self._related.new_collection(), self, model)
            )

        return models
734509
def connection(self):
        """"""
        if self._connection is None:

            self._connection = self.client[self.database_name]

            if self.disable_id_injector:
                incoming = self._connection._Database__incoming_manipulators
                for manipulator in incoming:
                    if isinstance(manipulator,
                                  pymongo.son_manipulator.ObjectIdInjector):
                        incoming.remove(manipulator)
                        LOG.debug("Disabling %s on mongodb connection to "
                                  "'%s'.",
                                  manipulator.__class__.__name__,
                                  self.database_name)
                        break

            for manipulator in self.manipulators:
                self._connection.add_son_manipulator(manipulator)
            LOG.info("Connected to mongodb on %s (database=%s)",
                     self.safe_connection_string, self.database_name)

        return self._connection
904499
def dispatch(self, collection, **kwargs):
        
        for inventory, method in self.methods[::-1]:
            if method(collection, **kwargs) is True:
                collection.parent = self.collection.children[inventory]
                return
        raise UndispatchedTextError("CapitainsCtsText not dispatched %s" % collection.id)
1374433
function(database, callback){
		var dbName = database.databaseName || database.name;
		var options = {
			name:dbName + '/_collections',
			service:feathersMongoColls(amityMongo.db.db(dbName))
		};
		amityMongo.amity_collManager.push(options);
		callback();
	}
1300209
def addCollector(self, collector):
        
        collector.setSchema(self)
        self.__collectors[collector.name()] = collector
40952
def collect_related(self, finder_funcs, obj, count, *args, **kwargs):
        
        collected = []
        for func in finder_funcs:
            gathered = func(obj, count, collected, *args, **kwargs)
            if gathered:
                collected += gathered
            if len(collected) >= count:
                return collected[:count]

        return collected
703968
def put(self, request, id=None, **kwargs):
        
        if id:
            obj = get_object_or_404(self.queryset(request), id=id)
            if not self.has_update_permission(request, obj):
                return HttpResponseForbidden(_('You do not have permission to perform this action.'))
            else:
                return self.update_object(request, obj)
        else:
            # No putting on a collection.
            return HttpResponseForbidden()
1007387
def insert_object(self, db_object):
        
        # Create object using the  to_dict() method.
        obj = self.to_dict(db_object)
        obj['active'] = True
        self.collection.insert_one(obj)