MapboxGL.SymbolLayer filter expression to check if id in array - react-native-mapbox-gl

I am trying to do the following with react-native-mapbox-gl
<MapboxGL.SymbolLayer
id="controlPointIcon"
filter={['all', ['in', 'id', this.state.nextPossible], ['==', 'type', 'alt']]}
style={mapStyle.iconControlPoint}
/>
The filter is supposed the match only if the given GeoJSON feature has its property id included in the array this.state.nextPossible and if the property type matches 'alt'.
I am clearly doing something wrong, the error I am getting says:
Invalide predicate: "id" ... NSInvalidArgumentException
reason [__NSCFNumber isEqualTOString:]: unrecognized selector sent to instance ...
Any idea how to solve this with mapbox filter expressions?

See https://github.com/react-native-mapbox-gl/maps/issues/70#issuecomment-499775185 in is a legacy filter syntax and not supported. Please use match instead.
<MapboxGL.SymbolLayer
id="controlPointIcon"
filter={
['all',
['match',
'id', this.state.nextPossible, true,
false
],
['==', 'type', 'alt']
]}
style={mapStyle.iconControlPoint}
/>

Related

Pymongo using hint on find_one gets AttributeError

Im need to preform a mongodb find_one query with pymongo but get AttributeError: 'NoneType' object has no attribute 'hint' since there are no results matching the filter
db.collection_name.find_one( filter=filter_query, projection={ _id: False, date: True, }, sort=[ ( date, pymongo.DESCENDING, ) ], ).hint('some_index')
also tried
db.collection_name.find_one( filter=filter_query, projection={ _id: False, date: True, }, sort=[ ( date, pymongo.DESCENDING, ) ], hint='some_index'
)
I know I can do it with find() but is there a way to do it with find_one?
The first approach definitely won't work. The second requires the hint parameter to be passed in the same format used to create the index, e.g. [('field', ASCENDING)].
https://pymongo.readthedocs.io/en/stable/api/pymongo/collection.html#pymongo.collection.Collection.find

ReferenceInput with null value through ra-data-graphql

"react-admin": "^4.1.3"
I have the following field definition on the <Create> page -
<TextInput source="name"/>
<TextInput source="description"/>
<ReferenceInput label="Parent" source="parent_id" reference="categories">
<SelectInput optionText="name"/>
</ReferenceInput>
With this setup when the value for the select input is left in the blank state it results in the following variables being sent as part of the payload
{
"objects": {
"name": "Some Value",
"description": "Description",
"parent_id": ""
}
}
And results in an error
{"errors":[
{"extensions":
{
"path":"$.selectionSet.insert_categories.args.objects",
"code":"data-exception"
},
"message":"invalid input syntax for type integer: \"\""
}
]}
Which makes sense because parent_id should be null and not included in the variables array.
As a workaround I have tried adding emptyValue={null} to the <SelectInput/> component. The only change when adding this is that a javascript error is thrown when the empty row is selected in the browser.
Warning: `value` prop on `input` should not be null. Consider using an empty string to clear the component or `undefined` for uncontrolled components.
The payload remains the same with "parent_id": "" still part of the variables array.
What do I need to do in order to properly setup a <ReferenceInput/> that allows null integer values to be submitted.

Creating an index for all active items

I have a collection of documents that follow this schema {label: String, status: Number}.
I want to introduce a new field, deleted_at: Date that will hold information if a document has already been deleted. Seems like a perfect use case for an index, to be able to search for all undeleted tasks.
CreateIndex({
name: "activeTasks",
source: Collection("tasks"),
terms: [
{ field: ["data", "deleted_at"] }
]
})
And then filter by undefined / null value in shell:
Paginate(Match(Index("activeTasks"), null))
Paginate(Match(Index("activeTasks"), undefined))
It returns nothing, even for documents where I explicitly set deleted_at to null.
That's not my point, though. I want to get documents that do not have the deleted_at defined at all, so that I do not have to update the whole collection.
PS. When I add document where deleted: "test" and query for it, the shell does return the expected result.
What do I don't get?
The reason is because FaunaDB doesn't support reading empty/null value the way you think it does. You need to use a special Bindings to do that.
Make sure to check out https://docs.fauna.com/fauna/current/tutorials/indexes/bindings.html#empty for a more thorough explanation and examples.
My understanding of how bindings work would yield the following code. I haven't tested it though and I'm not sure it works.
You need a special binding index:
CreateIndex({
name: "activeTasks",
source: [{
collection: Collection("tasks"),
fields: {
null_deleted_at: Query(
Lambda(
"doc",
Equals(Select(["data", "deleted_at"], Var("doc"), null), null)
)
)
}
}],
terms: [ {binding: "null_deleted_at"} ],
})
Usage:
Map(
Paginate(Match(Index("activeTasks"), true)),
Lambda("X", Get(Var("X")))
)

Which is valid format of :only-countries using VuePhoneNumberInput?

Which is valid format of :only-countries using VuePhoneNumberInput ?
I try :
<VuePhoneNumberInput
v-model="profileRow.phone"
#update="onUpdate"
:only-countries="[ 'es', 'en', 'us' ]"
/>
and got console error :
[Vue warn]: Error in nextTick: "Error: Key is undefined on item (keyField is 'null')"
found in
---> <RecycleScroller>
<CountrySelector>
<MazPhoneNumberInput>
Looking into source files I tried:
<VuePhoneNumberInput
v-model="profileRow.phone"
#update="onUpdate"
:only-countries="[ ['Afghanistan', 'af', '93'], ['Albania', 'al', '355'] ]"
/>
but got the same error.
"vue": "^2.6.11",
"vue-phone-number-input": "^1.1.9",
Thanks!
Instead of using lower case ISO2 country codes, you need to use all caps code like:
:only-countries="[ 'ES', 'US', 'AF', 'AL' ]"
Also, please verify for which country en is the code, If you meant to use the country code for "Great Britain", then you will need to use GB instead.

the keyAttr of data-dojo-props doesn't work

here is my html file :
...
<span data-dojo-id="staffStore" data-dojo-type="dojo.data.ItemFileReadStore" data-dojo-props='data:../../staff.json'></span>
<input data-dojo-type="dijit.form.ComboBox"
data-dojo-props="store: staffStore,
keyAttr: 'id',
searchAttr: 'staff_name',
autoComplete: true,
id: 'staff_name',
name:'staff_name',
value: '' "/>
...
and the json data goes as follows:
{
identifier: "id";,
label: "id",
items: [{id: 982483700, staff_name: "guanyu";},{id: 582057769, staff_name: "zhangfei";},{id: 166802994, staff_name: "zhaoyun";}]
}
here is my problem:
when i use post method i have got 'staff_name' in the searchAttr: 'staff_name' passed to the background-appication ,but i want to have the 'id' in the keyAttr: 'id' passed to background-application.in a word,i have passed made a wrong post action.can someone help me get out of this problem?
Use dijit/form/FilteringSelect not dijit/form/ComboBox.
You can enter any text into a ComboBox therefore it cannot return id which is the reason it returns text (or label or searchAttr). FilteringSelect allows only to chose one of options and therefore it can return id, which it does.
See it in action and experiment at jsFiddle: http://jsfiddle.net/phusick/QzQ38/