soda-angular
Socrata SODA client for Angular
Installation
npm install soda-angular --save
Also install these dev dependencies:
npm install geojson @types/geojson --save-dev
Usage
- Add the
SodaClientModule
to your module imports:
; ... @
- Create models for your dataset(s), decoated with a
@SodaDataset
that provides the dataset id:
;; @ city_file_number: string; permit_type: string; permit_class: string; permit_date: FloatingTimestamp; status: string; description_of_development: string; address: string; legal_description: string; neighbourhood_id: number; neighbourhood: string; zoning: string; location: Location; @ row_id: string; permit_number: string; permit_date: FloatingTimestamp; address: string; legal_description: string; neighbourhood: string; job_description: string; building_type: string; construction_value: number; zoning: string; location: Location; @ id: number; latitude: number; longitude: number; area: number; geometry: MultiPolygon;
- Extend
SodaContext
with your own service context. Provide the URL to the Socrata service of your choice via the@SodaHost
decorator, and create yourSodaResource
objects with a dataset models:
;; @@ public readonly developmentPermits: SodaResource<DevelopmentPermit>; public readonly buildingPermits: SodaResource<BuildingPermit>; { supersodaClient; thisdevelopmentPermits = DevelopmentPermit this; thisbuildingPermits = BuildingPermit this; }
- Inject your Context into your component, and query against it using fluent querying:
;; @ implements OnInit public DevelopmentPermits: DevelopmentPermit; public BuildingPermits: BuildingPermit; { } { thiscontextdevelopmentPermits ; thiscontextbuildingPermits ; }
Location type queries:
thiscontextdevelopmentPermits location plocation ); thiscontextbuildingPermits location plocation );
Geometry type queries:
;; thiscontextlegalParcels ; thiscontextlegalParcels ; thiscontextlegalParcels ;
Query builders
You can also use query builders for more control (including OR queries):
const builder = ; ; thiscontextdevelopmentPermits ;
Notes
- This is a work in progress, watch this repository for updates.
- Heavily inspired by Entity Framework.
- Filter grouping coming soon.
- Support for case-insensitive text matches is coming.
- Support for select-based functions are coming.
Additional Reading
- Socrata Developers
- yeg-dev-dashboard (Example project)
License
See LICENSE.