README
Arcgoose
Let's face it, writing ArcGIS REST API validation, casting and business logic boilerplate is a drag. That's why we wrote Arcgoose.
const connection = await arcgoose.connect({ url });
const Cat = await arcgoose.model(connection.layers.Cats, { name: String });
const cat = await Cat.findOne({ name: 'Grumpy' }).exec();
Arcgoose provides a straight-forward, schema-based solution to model your application data. It includes built-in type casting, validation, query building, business logic hooks and more, out of the box.*
* Arcgoose is a work in progress.
* Arcgoose is loosely based on the Mongoose syntax.
Installing
$ npm install --save arcgoose
Then, just import to your service or module:
import arcgoose from 'arcgoose';
Instructions
Connecting to ArcGIS Feature Server
Using the feature server URL:
const connection = await arcgoose.connect({ url });
Using the hosted feature layer item id:
const connection = await arcgoose.connect({ portalUrl, portalItemId });
Structure of the connection
JSON object:
{
url,
capabilities: { create, query, update, delete, editing },
layers: {
Cats: { id, url, fields, objectIdField },
Dogs: { id, url, fields, objectIdField },
},
tables: {
Rabbits: { id, url, fields, objectIdField },
},
}
Schemas
Arcgoose uses schemas for validation and casting of types that are not Esri-supported (e.g., arrays, objects, ...). Arcgoose uses the JSON Schema standard, and uses the Ajv library for validation.
const catSchema = {
type: 'object', // type should always be object
required: ['GlobalID', 'name']
properties: {
GlobalID: {
type: 'string',
},
name: {
type: 'string',
minLength: 3,
maxLength: 100,
},
details: {
type: 'object', // 'details' will be casted from a string to a javascript object
properties: {
color: {
type: 'string',
pattern: '^#(([0-9a-fA-F]{2}){3}|([0-9a-fA-F]){3})