--------------------- getCollectionAndRefresh ------------------------------
512359
@Override
    public CompletableFuture<Collection<V>> getCollectionAndRefreshAsync(String key, int expireSeconds) {
        return (CompletableFuture) refreshAsync(key, expireSeconds).thenCompose(v -> getCollectionAsync(key));
    }
924719
function getCollection() {

    var config = {
        properties: {
            collection: {
                description: 'Collection name and number of rows, 5 if omitted (ex: posts 10): '.magenta,
                type: 'string',
                required: true
            }
        }
    };

    prompt.start();
    prompt.message = ' > ';
    prompt.delimiter = '';

    return new Promise(function(resolve, reject) {
        prompt.get(config, function(err, result) {
            if (err) return reject(err);
            return resolve(result.collection);
        });
    });
}
619592
function()
	{
		if(this._collectionBinder)
		{
			this._collectionBinder.refreshIndexedBinders();
		}
		else
		{
			if(this._modelBindersMap)
			{
				this._modelBindersMap.refreshIndexedBinders();
			}
			if(this.subviews !== null)
			{
				for(var i = 0, l = this.subviews.length; i < l; i++) this.subviews[i].refreshIndexedBinders();
			}
		}
	}
1374614
function getCollection(docdbClient, nodeContext) {
    nodeContext.log(`Getting collection:\n${collectionName}\n`);
    var colldef = {id : collectionName};
    return new Promise((resolve, reject) => {
        docdbClient.readCollection(collectionUrl, (err, result) => {
            if (err) {
                if (err.code == HttpStatusCodes.NOTFOUND) {
                    docdbClient.createCollection(databaseUrl, colldef, { offerThroughput: 400 }, (err, created) => {
                        if (err) reject(err)
                        else resolve(created);
                    });
                } else {
                    reject(err);
                }
            } else {
                resolve(result);
            }
        });
    });
}
1306990
function(){
    if (this.collection){
      this.listenTo(this.collection, "add", this.addChildView, this);
      this.listenTo(this.collection, "remove", this.removeItemView, this);
      this.listenTo(this.collection, "reset", this.render, this);
    }
  }
705841
@Override
    public void clear()
    {
        eagerlyLoadDataCollection();
        if (getDataCollection() != null && !(getDataCollection() instanceof ProxyCollection))
        {
            ((Map)getDataCollection()).clear();
        }
    }
993507
public void refresh() {
		if (layer instanceof RasterLayer) {
			RasterLayer rLayer = (RasterLayer) layer;
			rLayer.setVisible(false);
			rLayer.getStore().clear();
			rLayer.setVisible(true);
		} else if (layer instanceof org.geomajas.gwt.client.map.layer.VectorLayer) {
			org.geomajas.gwt.client.map.layer.VectorLayer vl = (org.geomajas.gwt.client.map.layer.VectorLayer) layer;
			vl.setVisible(false);
			vl.clearSelectedFeatures();
			vl.getFeatureStore().clear();
			vl.setVisible(true);
		}
	}
930573
@Override
    public CompletableFuture<V> getAndRefreshAsync(String key, int expireSeconds) {
        return (CompletableFuture) refreshAsync(key, expireSeconds).thenCompose(v -> getAsync(key));
    }
741347
@Override
  public <T> void updateCollectionSchema(CollectionSchemaUpdate update, String collectionName) {
    CollectionMetaData cmd = cmdMap.get(collectionName);
    @SuppressWarnings("unchecked")
    Map<Object, T> collection = (Map<Object, T>) collectionsRef.get().get(collectionName);
    if((null == cmd) || (null == collection)) {
      throw new InvalidJsonDbApiUsageException("Collection by name '" + collectionName + "' not found. Create collection first.");
    }
    boolean reloadCollectionAsSomethingChanged = false;
    //We only take care of ADD and RENAME, the deletes will be taken care of automatically.
    if (null != update) {
      Map<String, RenameOperation> renOps = update.getRenameOperations();
      if (renOps.size() > 0) {
        reloadCollectionAsSomethingChanged = true;
        cmd.getCollectionLock().writeLock().lock();
        
        for(Entry<String, RenameOperation> updateEntry: renOps.entrySet()) {
          String oldKey = updateEntry.getKey();
          
          RenameOperation op = updateEntry.getValue();
          String newKey = op.getNewName();

          JsonWriter jw;
          try {
            jw = new JsonWriter(dbConfig, cmd, collectionName, fileObjectsRef.get().get(collectionName));
          } catch (IOException ioe) {
            logger.error("Failed to obtain writer for " + collectionName, ioe);
            throw new JsonDBException("Failed to save " + collectionName, ioe);
          }
          jw.renameKeyInJsonFile(collection.values(), true, oldKey, newKey);
        }
        cmd.getCollectionLock().writeLock().unlock();
      }
      
      Map<String, AddOperation> addOps = update.getAddOperations();
      if (addOps.size() > 0) {
        reloadCollectionAsSomethingChanged = true;
        cmd.getCollectionLock().writeLock().lock();
        
        for(Entry<String, AddOperation> updateEntry: addOps.entrySet()) {
          AddOperation op = updateEntry.getValue();
          
          Object value = null;
          if (op.isSecret()) {
            value = dbConfig.getCipher().encrypt((String)op.getDefaultValue());
          } else {
            value = op.getDefaultValue();
          }
          
          String fieldName = updateEntry.getKey();
          Method setterMethod = cmd.getSetterMethodForFieldName(fieldName);
          for(T object : collection.values()) {
            Util.setFieldValueForEntity(object, value, setterMethod);
          }
        }
        
        JsonWriter jw;
        try {
          jw = new JsonWriter(dbConfig, cmd, collectionName, fileObjectsRef.get().get(collectionName));
        } catch (IOException ioe) {
          logger.error("Failed to obtain writer for " + collectionName, ioe);
          throw new JsonDBException("Failed to save " + collectionName, ioe);
        }
        jw.reWriteJsonFile(collection.values(), true);
        cmd.getCollectionLock().writeLock().unlock();
      }
      
      Map<String, DeleteOperation> delOps = update.getDeleteOperations();
      if ((renOps.size() < 1 && addOps.size() < 1) && (delOps.size() > 0)) {
        //There were no ADD operations but there are some DELETE operations so we have to just flush the collection once
        //This would not have been necessary if there was even 1 ADD operation
        
        reloadCollectionAsSomethingChanged = true;
        cmd.getCollectionLock().writeLock().lock();
        
        JsonWriter jw;
        try {
          jw = new JsonWriter(dbConfig, cmd, collectionName, fileObjectsRef.get().get(collectionName));
        } catch (IOException ioe) {
          logger.error("Failed to obtain writer for " + collectionName, ioe);
          throw new JsonDBException("Failed to save " + collectionName, ioe);
        }
        jw.reWriteJsonFile(collection.values(), true);
        cmd.getCollectionLock().writeLock().unlock();
      }
      if (reloadCollectionAsSomethingChanged) {
        reloadCollection(collectionName);
      }
    }
  }
643628
def reloadCollections(self) :
        ""
        r = self.connection.session.get(self.collectionsURL)
        data = r.json()
        if r.status_code == 200 :
            self.collections = {}

            for colData in data["result"] :
                colName = colData['name']
                if colData['isSystem'] :
                    colObj = COL.SystemCollection(self, colData)
                else :
                    try :
                        colClass = COL.getCollectionClass(colName)
                        colObj = colClass(self, colData)
                    except KeyError :
                        if colData["type"] == CONST.COLLECTION_EDGE_TYPE :
                            colObj = COL.Edges(self, colData)
                        elif colData["type"] == CONST.COLLECTION_DOCUMENT_TYPE :
                            colObj = COL.Collection(self, colData)
                        else :
                            print(("Warning!! Collection of unknown type: %d, trying to load it as Collection nonetheless." % colData["type"]))
                            colObj = COL.Collection(self, colData)

                self.collections[colName] = colObj
        else :
            raise UpdateError(data["errorMessage"], data)
1230440
func (m *Manager) getRefreshTokenCollection() *mgo.Collection {
	return db.GetCollection(m.session, refreshTokenCollectionName)
}
1134433
protected void cacheCollection() {
        this.clear();
        for (FluentModelTImpl childResource : this.listChildResources()) {
            this.childCollection.put(childResource.childResourceKey(), childResource);
        }
    }
1024119
function loadCollection(collection, data) {
        return Q(collection.fetch()).then(function () {
            // delete all before running tests
            return Q.all(collection.models.slice().map(function (model) {
                return model.destroy();
            })).then(function () {
                chai_1.assert.equal(collection.models.length, 0, 'collection must be empty initially after destroy');
                return collection;
            });
        }).then(function (collection2) {
            // load sample data into fresh database
            chai_1.assert.equal(collection2, collection, 'same collection object');
            return Q.all(data.map(function (attrs) {
                return new TestModel(attrs, {
                    collection: collection2
                }).save();
            })).then(function () {
                chai_1.assert.equal(collection2.models.length, data.length, 'collection was updated by async events');
                return collection2;
            });
        });
    }
1283414
private void refresh() {
        try {
            // Invoke underlying getTuples unsynchronized.
            // This way it won't block tuple access, in case it is a long
            // running or expensive function.
            final CompletableFuture<? extends Collection<ResolverTuple>> fut = underlying.getTuples();

            // Publish future, needs synchronization, so close() method can cancel properly.
            synchronized(this) {
                // We create the whenCompleteAsync continuation with synchronization locked,
                // because the update code will want to clear the currentFut member-variable.
                // We must ensure it is set before.
                currentFut = fut.whenCompleteAsync(this::update, SCHEDULER);

                if (closed)  // Close may have set close bit while we were creating future.
                    fut.cancel(false);
            }
        } catch (Exception ex) {
            synchronized(this) {
                exception = ex;
            }
            reschedule(FAILURE_RESCHEDULE_DELAY);
        }
    }
180079
public function getCollection($name, $refresh = false)
    {
        if ($refresh || !array_key_exists($name, $this->_collections)) {
            $this->_collections[$name] = $this->selectCollection($name);
        }

        return $this->_collections[$name];
    }
897833
function collection() {
  var source = [];
  var api = {
    length: 0,

    push: function (item) {
      source.push(item);
      this.length += 1;

      api.fire('changed', { added: [item] });
    },

    splice: function (idx, count) {
      var removed = source.splice(idx, count);
      this.length = source.length;
      api.fire('changed', { removed: removed, removeIdx: idx });
    },

    get : function (idx) {
      return source[idx];
    },

    forEach: function (callback, thisArg) {
      source.forEach(callback, thisArg);
    }
  };

  eventify(api);

  return api;
}
706080
private void onFlushCollection(Map<String, List<DBObject>> collections)
    {
        for (String tableName : collections.keySet())
        {
            DBCollection dbCollection = mongoDb.getCollection(tableName);
            KunderaCoreUtils.printQuery("Persist collection:" + tableName, showQuery);
            try
            {
                dbCollection.insert(collections.get(tableName).toArray(new DBObject[0]), getWriteConcern(), encoder);
            }
            catch (MongoException ex)
            {
                throw new KunderaException("document is not inserted in " + dbCollection.getFullName()
                        + " collection. Caused By:", ex);
            }
        }

    }