Home > LIB_Classification > getNameByIndex
LIB_Classification.getNameByIndex() method
This API is provided as a beta preview for developers and may change based on feedback that we receive. Do not use this API in a production environment.
Warning: This API is now obsolete.
since EDA v3.2; dropped EDA v3.3
Get the name of the classification at the specified index
Signature
typescript
function getNameByIndex(
classificationIndex: ILIB_ClassificationIndex,
): Promise<
| { primaryClassificationName: string; secondaryClassificationName?: undefined | string }
| undefined
>;1
2
3
4
5
6
2
3
4
5
6
Parameters
Parameter | Type | Description |
|---|---|---|
classificationIndex | Classification index |
Returns
Promise<{ primaryClassificationName: string; secondaryClassificationName?: undefined | string } | undefined>
Name of the two-level classification
Example
javascript
// 1. 获取个人库 UUID
const libraryUuid = await eda.lib_LibrariesList.getPersonalLibraryUuid();
// 2. 创建两级测试分类,拿到两个索引对象(复用模块库)
const tag = Date.now();
const primaryName = `嘉立创示例_按索引查名一级_${tag}`;
const secondaryName = `嘉立创示例_按索引查名二级_${tag}`;
const primaryIndex = await eda.lib_Classification.createPrimary(libraryUuid, '1', primaryName);
const secondaryIndex = await eda.lib_Classification.createSecondary(
libraryUuid,
'1',
primaryIndex.primaryClassificationUuid,
secondaryName
);
// 3. 分别解析一级索引、二级索引的名称
const primaryNames = await eda.lib_Classification.getNameByIndex(primaryIndex);
const secondaryNames = await eda.lib_Classification.getNameByIndex(secondaryIndex);
// 4. 清理测试分类(查询类需要清理)
await eda.lib_Classification.deleteByUuid(libraryUuid, primaryIndex.primaryClassificationUuid);
console.log('primaryNames:', primaryNames);
console.log('secondaryNames:', secondaryNames);1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24