p5WFS_GetFeature() function
Smart js function to get data using WFS API and parse a response.
Usage
p5WFS_GetFeature(table, data)
LABEL | DESCRIPTION | EXAMPLE |
---|---|---|
table | string containing tablename from db with WFS API namespace | 'p5_default_db:CRM_PROCES' |
data | plainObject containing some of fields:
|
|
return |
Promise which resolves to an array of plainObject. If field values are strings, then it represents xlink. You can fetch this object by using featureID or primaryKey args in p5WFS_GetFeature |
|
For more information and usage of this parameters look into our wfs api documentation. |
Simple example:
p5WFS_GetFeature('p5_default_db:CRM_PROCES', {
Filter: '<ogc:PropertyIsEqualTo><ogc:PropertyName>PARENT_ID</ogc:PropertyName><ogc:Literal>7</ogc:Literal></ogc:PropertyIsEqualTo>',
sortBy: 'SORT_PRIO+A,ID',
maxFeatures: 100
}).then(function(features) {
console.log(features) // features is an array of objects
}).catch(function(e) {
console.log('Error', e)
})
Nested objects example:
p5WFS_GetFeature('p5_default_db__x3A__CRM_PROCES:PROCES', {
primaryKey: 100,
resolve: 'all',
resolveDepth: 3,
}).then(function(features) {
console.log(features) // features is an array of objects
}).catch(function(e) {
console.log('Error', e)
})
Back ref example (get PROCES under PROCES_INIT.123):
p5WFS_GetFeature('p5_default_db__x3A__CRM_PROCES:PROCES', {
primaryKey: 100,
resolve: 'all',
resolveDepth: 3,
backRefNS: 'p5_default_db__x3A__CRM_PROCES:PROCES_INIT',
backRefPK: 123,
backRefField: 'p5_default_db__x3A__CRM_PROCES:PROCES'
}).then(function(features) {
console.log(features) // features is an array of objects
}).catch(function(e) {
console.log('Error', e)
})
Back ref by xlink next data example (get PROCES under PROCES_INIT.123 with offset 10 - skip first 10 features):
?SERVICE=WFS
&VERSION=1.0.0
&TYPENAME=p5_default_db__x3A__CRM_PROCES:PROCES
&REQUEST=GetFeature
&backRefNS=p5_default_db__x3A__CRM_PROCES:PROCES_INIT
&backRefPK=123
&backRefField=p5_default_db__x3A__CRM_PROCES:PROCES
&startIndex=10
p5WFS_GetFeature('p5_default_db__x3A__CRM_PROCES:PROCES', {
primaryKey: 100,
resolve: 'all',
resolveDepth: 3,
backRefNS: 'p5_default_db__x3A__CRM_PROCES:PROCES_INIT',
backRefPK: 123,
backRefField: 'p5_default_db__x3A__CRM_PROCES:PROCES',
startIndex: 10
}).then(function(features) {
console.log(features) // features is an array of objects
}).catch(function(e) {
console.log('Error', e)
})