Skip to content
This repository has been archived by the owner on May 3, 2020. It is now read-only.

Commit

Permalink
Merge pull request #16 from samtstern/ss-new-indexes
Browse files Browse the repository at this point in the history
New Firestore indexes spec
  • Loading branch information
Jason-Abbott authored Jan 24, 2019
2 parents 3e855ae + e23dfdf commit 50855cb
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 28 deletions.
92 changes: 70 additions & 22 deletions syntaxes/index.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,17 @@
"items": {
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "The resource name of the index."
},
"collectionId": {
"collectionGroup": {
"type": "string",
"pattern": "^[a-zA-Z0-9_]+$",
"description": "The collection ID to which this index applies."
"description": "The collection group ID to which this index applies."
},
"queryScope": {
"enum": [
"COLLECTION",
"COLLECTION_GROUP"
],
"description": "The query scope to which this index applies."
},
"fields": {
"type": "array",
Expand All @@ -26,35 +29,80 @@
"pattern": "^[a-zA-Z0-9_\/\.]+$",
"description": "The path of the field. Special field paths __name__, __type__, and __scatter__ may be used."
},
"mode": {
"order": {
"enum": [
"ASCENDING",
"DESCENDING",
"MODE_UNSPECIFIED"
"DESCENDING"
],
"description": "The mode determines how a field is indexed."
"description": "The order determines how a field is indexed."
},
"arrayConfig": {
"enum": [
"CONTAINS"
],
"description": "The arrayConfig determines how an array field is indexed."
}
},
"uniqueItems": true,
"required": ["fieldPath"]
},
"minItems": 1
}
},
"required": ["collectionGroup", "queryScope", "fields"]
},
"minItems": 0
},
"fieldOverrides": {
"type": "array",
"items": {
"type": "object",
"properties": {
"collectionGroup": {
"type": "string",
"pattern": "^[a-zA-Z0-9_]+$",
"description": "The collection group ID to which this field override applies."
},
"state": {
"enum": [
"STATE_UNSPECIFIED",
"DISABLED",
"ENABLED",
"ENABLING",
"DISABLING",
"ERROR"
],
"description": "The state of the index. The state is read-only and is manipulated by using the enable and disable RPCs. During enabling, the process could result in an error, in which case the index will move to the ERROR state. The process can be recovered by either fixing the data that caused the error and retrying by calling enable or by aborting the index build by calling disable."
"fieldPath": {
"type": "string",
"pattern": "^[a-zA-Z0-9_\/\.]+$",
"description": "The field path to which this field override applies."
},
"indexes": {
"type": "array",
"items": {
"type": "object",
"properties": {
"queryScope": {
"enum": [
"COLLECTION",
"COLLECTION_GROUP"
],
"description": "The query scope to which this index applies."
},
"order": {
"enum": [
"ASCENDING",
"DESCENDING"
],
"description": "The order determines how a field is indexed."
},
"arrayConfig": {
"enum": [
"CONTAINS"
],
"description": "The arrayConfig determines how an array field is indexed."
}
},
"uniqueItems": true,
"required": ["order", "queryScope"]
},
"minItems": 0
}
},
"required": ["collectionId", "fields"]
"required": ["collectionGroup", "queryScope", "fields"]
},
"minItems": 1
"minItems": 0
}
},
"required": ["indexes"]
Expand Down
20 changes: 14 additions & 6 deletions syntaxes/sample.indexes.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
{
{
"indexes": [
{
"name": "my index",
"collectionId": "widgets",
"collectionGroup": "widgets",
"queryScope": "COLLECTION",
"fields": [
{ "fieldPath": "foo", "mode": "ASCENDING" },
{ "fieldPath": "bar", "mode": "DESCENDING" },
{ "fieldPath": "baz", "mode": "ASCENDING" }
{ "fieldPath": "foo", "arrayConfig": "CONTAINS" },
{ "fieldPath": "bar", "order": "DESCENDING" }
]
}
],
"fieldOverrides": [
{
"collectionGroup": "widgets",
"fieldPath": "baz",
"indexes": [
{ "order": "ASCENDING", "queryScope": "COLLECTION" }
]
}
]
Expand Down

0 comments on commit 50855cb

Please sign in to comment.