0.0.2 • Published 9 years ago

fieldtrip-records v0.0.2

Weekly downloads
6
License
-
Repository
-
Last release
9 years ago

records.js

A schema aware javascript datastore

Install

npm install .

Usage

Importing the module

// commonsjs
var RecordsJS = require('RecordsJS');

// amd
require(['RecordsJS'], function(RecordsJS)){
...
}

Creating a store

var records = new RecordsJS('records');

Storing an object

var geoJSONRecord = {
	"type": "Feature",
	"geometry": {
		"type": "Point",
		"coordinates": [125.6, 10.1]
	},
	"properties": {
		"name": "Dinagat Islands"
	}
};


records.put(1321344155, geoJSONRecord);

Retrieving an object

// Retrieve an object
records.get(1321344155);
{
	"type": "Feature",
	"geometry": {
		"type": "Point",
		"coordinates": [125.6, 10.1]
	},
	"properties": {
		"name": "Dinagat Islands"
	}
}
// Retrieve an object with metadata
records.get(1321344155, {metadata: true});
{
	_id: 1321344155,
	record: {
		"type": "Feature",
		"geometry": {
			"type": "Point",
			"coordinates": [125.6, 10.1]
		},
		"properties": {
			"name": "Dinagat Islands"
		}
	}
}

Delete an object

records.delete(1321344155);

Test

npm test

0.0.2

9 years ago

0.0.1

9 years ago