Skip to content

Commit b1b284e

Browse files
committed
Use the type field to determine if ingest is collection or item
The `type` field is required in STAC API 1.0.0 and using that field is preferable to a heuristic based on other field values. Connects #486
1 parent a833b98 commit b1b284e

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1010
### Changed
1111

1212
- Remove node streams-based ingest code to prepare for post-ingest notifications
13+
- Use the type field to determin if ingest is collection or item
1314

1415
## [1.1.0] - 2023-05-02
1516

src/lib/ingest.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ const COLLECTIONS_INDEX = process.env['COLLECTIONS_INDEX'] || 'collections'
66

77
export async function convertIngestObjectToDbObject(
88
// eslint-disable-next-line max-len
9-
/** @type {{ hasOwnProperty: (arg0: string) => any; collection: string; links: any[]; id: any; }} */ data
9+
/** @type {{ hasOwnProperty: (arg0: string) => any; type: string, collection: string; links: any[]; id: any; }} */ data
1010
) {
1111
let index = ''
1212
logger.debug('data', data)
13-
if (data && data.hasOwnProperty('extent')) {
13+
if (data && data.type === 'Collection') {
1414
index = COLLECTIONS_INDEX
15-
} else if (data && data.hasOwnProperty('geometry')) {
15+
} else if (data && data.type === 'Feature') {
1616
index = data.collection
1717
} else {
1818
return null

0 commit comments

Comments
 (0)