Create a new collection.

@param db
@param collectionName
@param options
@return
199937
public static MongoCollection<Document> createCollection(MongoDatabase db,
            String collectionName, CreateCollectionOptions options) {
        db.createCollection(collectionName, options);
        return db.getCollection(collectionName);
    }
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();
	}
129842
function (cb) {
          if (opts.dropCollection) {
            db.listCollections({name: collectionName})
              .toArray(function (err, items) {
                if (err) return cb(err)
                if (items.length) return coll.drop(cb)
                cb()
              })
          } else cb()
        }
1044004
def mode_new_collection():
    

    print globals()['mode_new_collection'].__doc__
    collection_name = raw_input("Collection name: ")
    item_attr_list = []
    collection_node_id = None
    if collection_name:
        collection_node_id = insert_node(name=collection_name, value=None)
        insert_query(name='select_link_node_from_node.sql', node_id=collection_node_id)
        item_attr = True
        while item_attr:
            item_attr = raw_input("Add a collection item attribute name: ")
            if item_attr:
                item_attr_list.append(item_attr)

    # if no collection name then exit
    selection = collection_name

    while selection:
        selection = select([
            'Add item',
            ])
        if selection == 'Add item':
            # create item
            add_item_with_attributes_to_collection(
                    collection_name=collection_name,
                    collection_node_id=collection_node_id,
                    item_attr_list=item_attr_list)

    if collection_node_id:
        print "Added collection name '{0}' with node id: {1}".format(collection_name, collection_node_id)
776678
function Iterator(db, options) {
  this.db = db;
  this.options = new IteratorOptions(options);
  this.iter = null;
  this.ended = false;
  this.total = 0;
  this.init();
}
882343
function (factory, options, context) {
                context = context || this.getContextByProperties();

                return context.createCollection(factory, options);
            }
697080
protected function newCollectionQuery(array &$options = array(), $modelClass = null)
    {
        $options = array_replace(array(
            'limit'  => null,
            'offset' => null,
        ), $options);

        $query = $this->newQuery($options, $modelClass);

        /*
         * Offset & limit
         */
        if (is_numeric($options['limit'])) {
            $options['limit'] = (int) $options['limit'];
        }
        if (is_numeric($options['offset'])) {
            $options['offset'] = (int) $options['offset'];
        }
        if (is_integer($options['limit'])) {
            $query->limit($options['limit']);
        }
        if (is_integer($options['offset']) && is_integer($options['limit'])) {
            $query->offset($options['offset']);
        }

        return $query;
    }
1059374
protected void initCollection() {
        boolean collectionExists = MongoUtils.collectionExists(getDatabase(), getCollectionName());
        if (!collectionExists) {
            LOGGER.info("Creating collection [" + getCollectionName() + "]...");
            getDatabase().createCollection(getCollectionName());
            MongoCollection<?> collection = getCollection();

            LOGGER.info("Creating index for field [" + getCollectionName() + "."
                    + MongodbQueue.COLLECTION_FIELD_ID + "]...");
            collection.createIndex(new Document().append(MongodbQueue.COLLECTION_FIELD_ID, 1),
                    new IndexOptions().unique(true));

            LOGGER.info("Creating index for field [" + getCollectionName() + "."
                    + MongodbQueue.COLLECTION_FIELD_EPHEMERAL_KEY + "]...");
            collection.createIndex(
                    new Document().append(MongodbQueue.COLLECTION_FIELD_EPHEMERAL_KEY, 1),
                    new IndexOptions());

            LOGGER.info("Creating index for field [" + getCollectionName() + "."
                    + MongodbQueue.COLLECTION_FIELD_QUEUE_TIME + "]...");
            collection.createIndex(
                    new Document().append(MongodbQueue.COLLECTION_FIELD_QUEUE_TIME, 1),
                    new IndexOptions());

            LOGGER.info("Creating index for field [" + getCollectionName() + "."
                    + MongodbQueue.COLLECTION_FIELD_TIME + "]...");
            collection.createIndex(new Document().append(MongodbQueue.COLLECTION_FIELD_TIME, 1),
                    new IndexOptions());

        }
    }
223318
@Override
    public CollectorItem createCollectorItemSelectOptions(CollectorItem item, Map<String, Object> allOptions, Map<String, Object> uniqueOptions) {
        Collector collector =  collectorRepository.findOne(item.getCollectorId());
        Map<String,Object> uniqueFieldsFromCollector = collector.getUniqueFields();
        List<CollectorItem> existing = customRepositoryQuery.findCollectorItemsBySubsetOptions(
                item.getCollectorId(), allOptions, uniqueOptions,uniqueFieldsFromCollector);

        if (!CollectionUtils.isEmpty(existing)) {
            CollectorItem existingItem = existing.get(0);
            existingItem.getOptions().putAll(item.getOptions());
            return collectorItemRepository.save(existingItem);
        }
        return collectorItemRepository.save(item);
    }
240643
function ( db ) {
          try {
            if ( Array.isArray( options.schemas ) ) {
              options.schemas.forEach(
                function ( schema ) {
                  var keys = Object.keys( schema );

                  db.model( keys[ 0 ], schema[ keys[ 0 ] ] );
                }
              );
            }

            return db;
          } catch ( err ) {
            throw err;
          }
        }
337227
@SuppressWarnings({ "unchecked", "rawtypes" })
	public static <T> Collection<T> create(Class<?> collectionType) {
		Collection<T> list = null;
		if (collectionType.isAssignableFrom(AbstractCollection.class)) {
			// 抽象集合默认使用ArrayList
			list = new ArrayList<>();
		}

		// Set
		else if (collectionType.isAssignableFrom(HashSet.class)) {
			list = new HashSet<>();
		} else if (collectionType.isAssignableFrom(LinkedHashSet.class)) {
			list = new LinkedHashSet<>();
		} else if (collectionType.isAssignableFrom(TreeSet.class)) {
			list = new TreeSet<>();
		} else if (collectionType.isAssignableFrom(EnumSet.class)) {
			list = (Collection<T>) EnumSet.noneOf((Class<Enum>) ClassUtil.getTypeArgument(collectionType));
		}

		// List
		else if (collectionType.isAssignableFrom(ArrayList.class)) {
			list = new ArrayList<>();
		} else if (collectionType.isAssignableFrom(LinkedList.class)) {
			list = new LinkedList<>();
		}

		// Others，直接实例化
		else {
			try {
				list = (Collection<T>) ReflectUtil.newInstance(collectionType);
			} catch (Exception e) {
				throw new UtilException(e);
			}
		}
		return list;
	}
857199
public WriteResult insert(DBObject dbObject, QueryOptions options) {
        if(options != null && (options.containsKey("w") || options.containsKey("wtimeout"))) {
            // Some info about params: http://api.mongodb.org/java/current/com/mongodb/WriteConcern.html
            return dbCollection.insert(dbObject, new WriteConcern(options.getInt("w", 1),
                    options.getInt("wtimeout", 0)));
        }else {
            return dbCollection.insert(dbObject);
        }
    }
859867
public static function create($collection, $id = null, $database = null)
    {
        if ($collection instanceof \Phalcon\Mvc\Collection) {
            $id = $collection->getId();
            $collection = $collection->getSource();
        }
        if ($id instanceof \Phalcon\Mvc\Collection) {
            $id = $id->getId();
        }
        if (!$id instanceof \MongoId && $id !== null) {
            $id = new \MongoId($id);
        }

        return parent::create($collection, $id, $database);
    }
503189
function(collection, callback){
  	// Prep the collection name.
  	var colName = collection.name.split('.');
  	var dbName = colName.shift();
  	colName = colName.join('.');

  	var database = amityMongo.db.db(dbName);

  	var options = {
  		name:dbName + '/' + colName,
  		service:feathersMongo({collection:database.collection(collection.name)})
  	};
  	amityMongo.amity_collections.push(options);
  	callback();
	}
35857
function(connectionName, collectionName, options, stream) {

      options = options || {};

      var connectionObject = connections[connectionName];
      if (!connectionObject) return stream.end(Errors.InvalidConnection);

      var collection = connectionObject.collections[collectionName];
      if (!collection) return stream.end(Errors.CollectionNotRegistered);

      collection.stream(options, stream);
    }
928935
public function createCollection($name, array $options = [])
    {
        if (isset($this->collections[$name])) {
            throw new RuntimeException('collection already exists');
        }

        $this->collections[$name] = [
            'collection' => new MockCollection($name, $this),
            'options' => $options
        ];

        return [
            'ok' => 1.0
        ];
    }
1154572
@SuppressWarnings("deprecation")
    public Datastore createDatastore(final MongoClient mongoClient, final String dbName) {
        return new DatastoreImpl(this, mongoClient, dbName);
    }