當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。