Skip to content

Commit 4d96ed0

Browse files
committed
Dedupe CollectionMetadata type
1 parent 0b5136b commit 4d96ed0

File tree

2 files changed

+67
-34
lines changed

2 files changed

+67
-34
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
2828
The type `ArangoSearchViewProperties & ViewDescription` can be used
2929
to represent the same structure.
3030

31+
### Changed
32+
33+
- Removed `CollectionMetadata` fields from `CollectionProperties` type
34+
35+
Methods that previously returned `CollectionProperties` now return
36+
`CollectionMetadata & CollectionProperties`.
37+
3138
### Added
3239

3340
- Added `auth` option to configuration

src/collection.ts

Lines changed: 60 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,33 @@
1414
import { ArangoResponseMetadata, Params } from "./connection";
1515
import { ArrayCursor } from "./cursor";
1616
import { Database } from "./database";
17-
import { Document, DocumentData, DocumentMetadata, DocumentSelector, Edge, EdgeData, _documentHandle } from "./documents";
17+
import {
18+
Document,
19+
DocumentData,
20+
DocumentMetadata,
21+
DocumentSelector,
22+
Edge,
23+
EdgeData,
24+
_documentHandle,
25+
} from "./documents";
1826
import { isArangoError } from "./error";
19-
import { EnsureFulltextIndexOptions, EnsureGeoIndexOptions, EnsureHashIndexOptions, EnsurePersistentIndexOptions, EnsureSkiplistIndexOptions, EnsureTtlIndexOptions, FulltextIndex, GeoIndex, HashIndex, Index, IndexSelector, PersistentIndex, SkiplistIndex, TtlIndex, _indexHandle } from "./indexes";
27+
import {
28+
EnsureFulltextIndexOptions,
29+
EnsureGeoIndexOptions,
30+
EnsureHashIndexOptions,
31+
EnsurePersistentIndexOptions,
32+
EnsureSkiplistIndexOptions,
33+
EnsureTtlIndexOptions,
34+
FulltextIndex,
35+
GeoIndex,
36+
HashIndex,
37+
Index,
38+
IndexSelector,
39+
PersistentIndex,
40+
SkiplistIndex,
41+
TtlIndex,
42+
_indexHandle,
43+
} from "./indexes";
2044
import { Blob } from "./lib/blob";
2145
import { COLLECTION_NOT_FOUND, DOCUMENT_NOT_FOUND } from "./util/codes";
2246
import { Patch } from "./util/types";
@@ -179,28 +203,6 @@ export type ValidationProperties = {
179203
* An object defining the properties of a collection.
180204
*/
181205
export type CollectionProperties = {
182-
/**
183-
* The collection name.
184-
*/
185-
name: string;
186-
/**
187-
* A globally unique identifier for this collection.
188-
*/
189-
globallyUniqueId: string;
190-
/**
191-
* An integer indicating the collection loading status.
192-
*/
193-
status: CollectionStatus;
194-
/**
195-
* An integer indicating the collection type.
196-
*/
197-
type: CollectionType;
198-
/**
199-
* @internal
200-
*
201-
* Whether the collection is a system collection.
202-
*/
203-
isSystem: boolean;
204206
/**
205207
* A human-readable representation of the collection loading status.
206208
*/
@@ -1349,7 +1351,9 @@ export interface DocumentCollection<T extends object = any>
13491351
options?: CreateCollectionOptions & {
13501352
type?: CollectionType;
13511353
}
1352-
): Promise<ArangoResponseMetadata & CollectionProperties>;
1354+
): Promise<
1355+
ArangoResponseMetadata & CollectionMetadata & CollectionProperties
1356+
>;
13531357
/**
13541358
* Retrieves the collection's properties.
13551359
*
@@ -1361,7 +1365,9 @@ export interface DocumentCollection<T extends object = any>
13611365
* // data contains the collection's properties
13621366
* ```
13631367
*/
1364-
properties(): Promise<ArangoResponseMetadata & CollectionProperties>;
1368+
properties(): Promise<
1369+
ArangoResponseMetadata & CollectionMetadata & CollectionProperties
1370+
>;
13651371
/**
13661372
* Replaces the properties of the collection.
13671373
*
@@ -1376,7 +1382,9 @@ export interface DocumentCollection<T extends object = any>
13761382
*/
13771383
properties(
13781384
properties: CollectionPropertiesOptions
1379-
): Promise<ArangoResponseMetadata & CollectionProperties>;
1385+
): Promise<
1386+
ArangoResponseMetadata & CollectionMetadata & CollectionProperties
1387+
>;
13801388
/**
13811389
* Retrieves information about the number of documents in a collection.
13821390
*
@@ -1389,7 +1397,10 @@ export interface DocumentCollection<T extends object = any>
13891397
* ```
13901398
*/
13911399
count(): Promise<
1392-
ArangoResponseMetadata & CollectionProperties & CollectionCount
1400+
ArangoResponseMetadata &
1401+
CollectionMetadata &
1402+
CollectionProperties &
1403+
CollectionCount
13931404
>;
13941405
/**
13951406
* (RocksDB only.) Instructs ArangoDB to recalculate the collection's
@@ -1420,6 +1431,7 @@ export interface DocumentCollection<T extends object = any>
14201431
*/
14211432
figures(): Promise<
14221433
ArangoResponseMetadata &
1434+
CollectionMetadata &
14231435
CollectionProperties &
14241436
CollectionCount &
14251437
CollectionFigures
@@ -1436,7 +1448,10 @@ export interface DocumentCollection<T extends object = any>
14361448
* ```
14371449
*/
14381450
revision(): Promise<
1439-
ArangoResponseMetadata & CollectionProperties & CollectionRevision
1451+
ArangoResponseMetadata &
1452+
CollectionMetadata &
1453+
CollectionProperties &
1454+
CollectionRevision
14401455
>;
14411456
/**
14421457
* Retrieves the collection checksum.
@@ -3049,12 +3064,18 @@ export class Collection<T extends object = any>
30493064
}
30503065

30513066
properties(properties?: CollectionPropertiesOptions) {
3052-
if (!properties) return this._get<CollectionProperties>("properties");
3053-
return this._put<CollectionProperties>("properties", properties);
3067+
if (!properties)
3068+
return this._get<CollectionMetadata & CollectionProperties>("properties");
3069+
return this._put<CollectionMetadata & CollectionProperties>(
3070+
"properties",
3071+
properties
3072+
);
30543073
}
30553074

30563075
count() {
3057-
return this._get<CollectionProperties & CollectionCount>("count");
3076+
return this._get<
3077+
CollectionMetadata & CollectionProperties & CollectionCount
3078+
>("count");
30583079
}
30593080

30603081
async recalculateCount() {
@@ -3064,12 +3085,17 @@ export class Collection<T extends object = any>
30643085

30653086
figures() {
30663087
return this._get<
3067-
CollectionProperties & CollectionCount & CollectionFigures
3088+
CollectionMetadata &
3089+
CollectionProperties &
3090+
CollectionCount &
3091+
CollectionFigures
30683092
>("figures");
30693093
}
30703094

30713095
revision() {
3072-
return this._get<CollectionProperties & CollectionRevision>("revision");
3096+
return this._get<
3097+
CollectionMetadata & CollectionProperties & CollectionRevision
3098+
>("revision");
30733099
}
30743100

30753101
checksum(options?: CollectionChecksumOptions) {

0 commit comments

Comments
 (0)