• Stars
    star
    352
  • Rank 120,622 (Top 3 %)
  • Language
    JavaScript
  • License
    Apache License 2.0
  • Created about 13 years ago
  • Updated almost 10 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

an isomorphic Resource engine for JavaScript

Synopsis

  • Isomorphic Resource engine for JavaScript
  • Resources are business logic wrapped in prototypical models with schema and validation
  • Resources support several data-providers
    • Memory
    • File-System
    • CouchDB
    • MongoDB
    • REST
    • socket.io

Status

Build Status

Features

Installation

$ [sudo] npm install resourceful

Usage

Simple case

var resourceful = require('resourceful');

var Creature = resourceful.define('creature', function () {
  //
  // Specify a storage engine
  //
  this.use('couchdb');

  //
  // Specify some properties with validation
  //
  this.string('diet');
  this.bool('vertebrate');
  this.array('belly');

  //
  // Specify timestamp properties
  //
  this.timestamps();
});

//
// Now that the `Creature` prototype is defined
// we can add custom logic to be available on all instances
//
Creature.prototype.feed = function (food) {
  this.belly.push(food);
};

Engines

Documentation

See the wiki for more documention.

API

Resource Constructor Methods

These methods are available on all user-defined resource constructors, as well as on the default resourceful.Resource constructor.

  • Resource.get(id, [callback]): Fetch a resource by id.
  • Resource.update(id, properties, [callback]): Update a resource with properties.
  • Resource.destroy(id, [callback]): Destroy a resource by id.
  • Resource.all([callback]): Fetches all resources of this type.
  • Resource.find(properties, [callback]): Find all resources of this type which satisfy properties conditions.
  • Resource.save(inst, [callback]): Saves the specified resource instance inst by overwriting all properties.
  • Resource.create(properties, [callback]): Creates a new instance of the Resource with the specified properties.
  • Resource.new(properties): Instantiates a new instance of the Resource with the properties.

Resource Instance Methods

  • Resource.prototype.save([callback])
  • Resource.prototype.update(properties, [callback])
  • Resource.prototype.destroy([callback])
  • Resource.prototype.reload([callback])

Relationship Constructor Methods

These methods are available on all user-defined resource constructors which are in a relationship

  • Parent.children(id, [callback]): Fetches all the children for the specified id.
  • Parent.createChild(id, properties, [callback]): Create a child for id with the specified properties.
  • Child.byParent(id, [callback]): Fetches all the children for the parent given by id.

Relationship Instance Methods

  • Parent.prototype.children([callback])
  • Parent.prototype.createChild(properties, [callback])
  • Child.prototype.parent([callback]): Fetches the parent of the given child instance.

Relational Resources

Resourceful supports a simple Resource.parent API, supports one-one, one-many, and many-many relationships.

Documentation

Tests

All tests are written with vows and should be run with npm:

  $ npm test

License

Copyright 2012 Nodejitsu, Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

More Repositories

1

director

a tiny and isomorphic URL router for JavaScript
JavaScript
5,622
star
2

prompt

a beautiful command-line prompt for node.js
JavaScript
1,860
star
3

cradle

a high-level CouchDB client for Node.js
JavaScript
1,377
star
4

flatiron

framework components for node.js and the browser
JavaScript
1,340
star
5

plates

Light-weight, logic-less, DSL-free, templates for all javascript environments!
JavaScript
830
star
6

revalidator

A cross-browser / node.js validator powered by JSON Schema
JavaScript
592
star
7

blacksmith

A generic static site generator built using flatiron, plates, and marked.
JavaScript
556
star
8

restful

reflect RESTful Director routers from Resourceful resources
JavaScript
236
star
9

cliff

Your CLI formatting friend
JavaScript
194
star
10

union

A hybrid buffered / streaming middleware kernel backwards compatible with connect.
JavaScript
136
star
11

utile

A drop-in replacement for `util` with some additional advantageous functions
JavaScript
95
star
12

socketful

reflect socket.io event maps from Resourceful resources
JavaScript
44
star
13

director-reflector

reflect isomorphic HTTP client API wrappers from Director routers
JavaScript
21
star
14

viewful

a tiny and isomorphic consolidated view engine for JavaScript
JavaScript
19
star
15

cli-config

Encapsulated commands for managing configuration in flatiron CLI apps
JavaScript
17
star
16

www

The public web presence for flatiron
CSS
12
star
17

director-explorer

HTML / Text view of `Director.router` instances
JavaScript
12
star
18

commandful

reflect Command Line Interfaces from Resourceful resources
JavaScript
12
star
19

http-users

Encapsulated routes and resources for managing users in flatiron HTTP apps
JavaScript
11
star
20

cli-users

Encapsulated commands for managing users in flatiron CLI apps
JavaScript
10
star
21

formful

reflect HTML forms from Resourceful resources
JavaScript
10
star
22

blacksmith-sites

a collection of pre-built site generators for the blacksmith engine
JavaScript
7
star
23

hello-world-flatiron-api

Sample Flatironjs Application - Hello World API
JavaScript
7
star
24

cortex.js

A front-end framework
JavaScript
4
star
25

broadway-godot

Plugin that enables godot on the broadway instance through magic
JavaScript
1
star