当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript Graph.vertexCollection方法代码示例

本文整理汇总了TypeScript中arangojs.Graph.vertexCollection方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Graph.vertexCollection方法的具体用法?TypeScript Graph.vertexCollection怎么用?TypeScript Graph.vertexCollection使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在arangojs.Graph的用法示例。


在下文中一共展示了Graph.vertexCollection方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: getVertexCollection

  /**
   * gets a new GraphVertexCollection instance with the given name for this graph.
   *
   * @param  {string} collectionName The handle of the vertex to retrieve.
   * This can be either the _id or the _key of a vertex in the collection,
   * or a vertex (i.e. an object with an _id or _key property).
   * @return  {Object} created vertex
   */
  async getVertexCollection(collectionName: string): Promise<Object> {
    if (_.isNil(collectionName)) {
      throw new Error('missing vertex collection name');
    }

    const collection = await this.graph.vertexCollection(collectionName);
    return collection;
  }
开发者ID:restorecommerce,项目名称:chassis-srv,代码行数:16,代码来源:graph.ts

示例2: getVertex

 /**
  * Retreives the vertex with the given documentHandle from the collection.
  *
  * @param  {string} collectionName vertex collection name
  * @param  {string} documentHandle The handle of the vertex to retrieve.
  * This can be either the _id or the _key of a vertex in the collection,
  * or a vertex (i.e. an object with an _id or _key property).
  * @return  {Object} created vertex
  */
 async getVertex(collectionName: string, documentHandle: string): Promise<Object> {
   if (_.isNil(collectionName)) {
     throw new Error('missing vertex collection name');
   }
   if (_.isNil(documentHandle)) {
     throw new Error('missing document handle');
   }
   const collection = this.graph.vertexCollection(collectionName);
   const doc = await collection.vertex(documentHandle);
   return doc;
 }
开发者ID:restorecommerce,项目名称:chassis-srv,代码行数:20,代码来源:graph.ts

示例3: removeVertex

 /**
  * Deletes the vertex with the given documentHandle from the collection.
  *
  * @param {string} collectionName vertex collection name
  * @param  {string[]} documentHandles An array of the documentHandles to be removed.
  * This can be either the _id or the _key of a vertex in the collection,
  * or a vertex (i.e. an object with an _id or _key property).
  * @return  {Object} removed vertex
  */
 async removeVertex(collectionName: string, documentHandles: string | string[]): Promise<any> {
   if (_.isNil(collectionName)) {
     throw new Error('missing vertex collection name');
   }
   if (_.isNil(documentHandles)) {
     throw new Error('missing document handle property');
   }
   if (!_.isArray(documentHandles)) {
     documentHandles = [documentHandles as string];
   }
   const collection = this.graph.vertexCollection(collectionName);
   let removedVertexList = [];
   for (let documentHandle of documentHandles) {
     removedVertexList.push(await collection.remove(documentHandle));
   }
   if (removedVertexList.length === 1) {
     return removedVertexList[0];
   }
   return removedVertexList;
 }
开发者ID:restorecommerce,项目名称:chassis-srv,代码行数:29,代码来源:graph.ts

示例4: createVertex

 /**
  * create a new Vertex with given data.
  *
  * @param  {string} collectionName vertex collection name
  * @param  {Object} data data for vertex
  * @return  {Object} created vertex
  */
 async createVertex(collectionName: string, data: any): Promise<any> {
   if (_.isNil(collectionName)) {
     throw new Error('missing vertex collection name');
   }
   if (_.isNil(data)) {
     throw new Error('missing data for vertex');
   }
   const collection = this.graph.vertexCollection(collectionName);
   let docs = _.cloneDeep(data);
   if (!_.isArray(docs)) {
     docs = [docs];
   }
   _.forEach(docs, (document, i) => {
     docs[i] = sanitizeInputFields(document);
   });
   const results = await collection.save(docs);
   _.forEach(results, (result) => {
     if (result.error === true) {
       throw new Error(result.errorMessage);
     }
   });
   return _.map(docs, sanitizeOutputFields);
 }
开发者ID:restorecommerce,项目名称:chassis-srv,代码行数:30,代码来源:graph.ts


注:本文中的arangojs.Graph.vertexCollection方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。