Creates a collection.
358411
public function createCollection(Collection $collection): Collection
    {
        $query = $this->connection->createQueryBuilder()
            ->insert('ngbm_collection')
            ->values(
                [
                    'id' => ':id',
                    'status' => ':status',
                    'start' => ':start',
                    'length' => ':length',
                    'translatable' => ':translatable',
                    'main_locale' => ':main_locale',
                    'always_available' => ':always_available',
                ]
            )
            ->setValue(
                'id',
                $collection->id !== null ?
                    (int) $collection->id :
                    $this->connectionHelper->getAutoIncrementValue('ngbm_collection')
            )
            ->setParameter('status', $collection->status, Type::INTEGER)
            ->setParameter('start', $collection->offset, Type::INTEGER)
            ->setParameter('length', $collection->limit, Type::INTEGER)
            ->setParameter('translatable', $collection->isTranslatable, Type::BOOLEAN)
            ->setParameter('main_locale', $collection->mainLocale, Type::STRING)
            ->setParameter('always_available', $collection->alwaysAvailable, Type::BOOLEAN);

        $query->execute();

        $collection->id = $collection->id ?? (int) $this->connectionHelper->lastInsertId('ngbm_collection');

        return $collection;
    }
723991
protected function populateModuleCollection()
    {
        $this->modules = new Collection;

        foreach ($this->moduleClasses as $moduleClass) {

            $instance = $this->instantiateClass($moduleClass);

            if ($instance instanceof ModuleGeneratorInterface) {
                $this->storeModulesForGenerator($instance);
                continue;
            }

            // instance is a module
            $this->storeModule($instance);
        }

        return $this;
    }
795540
public function create($data)
    {
        $collection = new DescriptorCollection();

        foreach ($data as $type) {
            $collection->add($this->createDescriptorForType($type));
        }

        return $collection;
    }
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;
	}
882343
function (factory, options, context) {
                context = context || this.getContextByProperties();

                return context.createCollection(factory, options);
            }
1003723
function Collection(options) {
  Base.call(this, options);
  this.define('lists', {});
  this.define('_items', {});
  this.define('Item', this.options.Item || require('./item'));
  this.define('List', this.options.List || require('./list'));
  mixins(this);

  /**
   * Get an object representing the current items on the instance.
   *
   * ```js
   * var items = this.items;
   * ```
   *
   * @return {Object} Object of items
   */

  Object.defineProperty(this, 'items', {
    enumerable: false,
    configurable: true,
    get: function () {
      return this._items;
    },
    set: function (items) {
      lazy.forIn(items, function (item, key) {
        delete this._items[key];
        delete this[key];
        this.set(key, item);
      }, this);
    }
  });
}
619983
@NonNull
    public <T> List<T> create(@NonNull Collection<Class<? extends T>> classes) {
        final List<T> result = new ArrayList<>();
        for (Class<? extends T> clazz : classes) {
            final T instance = create(clazz);
            if (instance != null) {
                result.add(instance);
            }
        }
        return result;
    }
1101503
function() {
    var collection = [];
    var scope = this;
    this.each(function() {
      var p = scope.parent(this[0]);
      if(p && p[0]) collection.push(p[0]);
    });
    return new SpahQL(collection);
  }
849213
public function createCollection($name, $capped = null, $capped_size = null, $max_elements = null)
    {
        $this->time->start();
        $return = parent::createCollection($name, $capped, $size, $max);
        $time = $this->time->stop();

        $this->log(array(
            'type'   => 'createCollection',
            'name'   => $name,
            'options' => $options
        ));

        return $return;
    }
256468
@SuppressWarnings("unchecked")
  private Collection<Object> newCollection(Class<?> type) {
    if (SortedSet.class.isAssignableFrom(type)) return new TreeSet();
    else if (LinkedHashSet.class.isAssignableFrom(type)) return new LinkedHashSet();
    else if (Set.class.isAssignableFrom(type)) return new HashSet();
    else if (List.class.isAssignableFrom(type)) return new ArrayList();
    else {
      throw new ParameterException("Parameters of Collection type '" + type.getSimpleName()
                                  + "' are not supported. Please use List or Set instead.");
    }
  }
278507
@Override
  public <T> void createCollection(String collectionName) {
    CollectionMetaData cmd = cmdMap.get(collectionName);
    if (null == cmd) {
      throw new InvalidJsonDbApiUsageException(
          "No class found with @Document Annotation and attribute collectionName as: " + collectionName);
    }
    @SuppressWarnings("unchecked")
    Map<Object, T> collection = (Map<Object, T>) collectionsRef.get().get(collectionName);
    if (null != collection) {
      throw new InvalidJsonDbApiUsageException("Collection by name '" + collectionName + "' already exists.");
    }

    cmd.getCollectionLock().writeLock().lock();

    // Some other thread might have created same collection when this thread reached this point
    if(collectionsRef.get().get(collectionName) != null) {
      return;
    }

    try {
      String collectionFileName = collectionName + ".json";
      File fileObject = new File(dbConfig.getDbFilesLocation(), collectionFileName);
      try {
        fileObject.createNewFile();
      } catch (IOException e) {
        logger.error("IO Exception creating the collection file {}", collectionFileName, e);
        throw new InvalidJsonDbApiUsageException("Unable to create a collection file for collection: " + collectionName);
      }

      if (Util.stampVersion(dbConfig, fileObject, cmd.getSchemaVersion())) {
        collection = new LinkedHashMap<Object, T>();
        collectionsRef.get().put(collectionName, collection);
        contextsRef.get().put(collectionName, JXPathContext.newContext(collection.values())) ;
        fileObjectsRef.get().put(collectionName, fileObject);
        cmd.setActualSchemaVersion(cmd.getSchemaVersion());
      } else {
        fileObject.delete();
        throw new JsonDBException("Failed to stamp version for collection: " + collectionName);
      }
    } finally {
      cmd.getCollectionLock().writeLock().unlock();
    }
  }
836031
def create(cls, name, database=SYSTEM_DATABASE, type=2):
        

        client = Client.instance()
        api = client.api

        if client.database != database:
            database = client.database

        collection_data = {
            'name': name,
            'type': type,
        }

        data = api.collection.post(data=collection_data)

        collection = Collection(
            name=name,
            database=database,
            api_resource=api.collection,
            api=api,
            kwargs=data
        )

        return collection
1016366
private static <E> Collection<E> toCollection(Iterable<E> iterable) {
		return (iterable instanceof Collection) ? (Collection<E>)iterable : Lists.newArrayList(iterable.iterator());
	}
42536
public function createCollection($collection, $options = [])
    {
        if (is_array($collection)) {
            list($database, $collectionName) = $collection;
        } else {
            $database = null;
            $collectionName = $collection;
        }
        $this->beginProfile($token = "    > create collection " . $this->composeCollectionLogName($collection) . " ...");
        $this->db->getDatabase($database)->createCollection($collectionName, $options);
        $this->endProfile($token);
    }
1060828
function (connectionName, collectionName, definition, cb) {

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

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

      collection.createTable(cb);
    }
709781
@SuppressWarnings("rawtypes")
    public static Collection createConcreteCollection(Class interfaceType) {
        Collection elements;
        if (interfaceType.equals(List.class) || interfaceType.equals(Collection.class)) {
            elements = new ArrayList();
        }
        else if (interfaceType.equals(SortedSet.class)) {
            elements = new TreeSet();
        }
        else {
            elements = new HashSet();
        }
        return elements;
    }
1035194
public function createFromCollection(Collection $collection)
    {
        $this->operator = new CollectionOperator($collection, $this->request);
        $this->prepare();

        return $this;
    }