Skip to content

Instantly share code, notes, and snippets.

@deanlandolt
Forked from brianleroux/person.js
Created October 13, 2010 23:01
Show Gist options
  • Save deanlandolt/625134 to your computer and use it in GitHub Desktop.
Save deanlandolt/625134 to your computer and use it in GitHub Desktop.
// when defined in js json-schema doesn't need no quoted keys
// and you can can use the native type classes if you don't have any options
var Person = {
// properties and validations
properties: {
{ id: {type: "number", unique:true, nullable:false },
{ email:String, unique:true, nullable:false, minimumValue:1, maximumValue:55, pattern: '[a-b]' },
{ salt: String },
{ pswd: String },
{ active: {type: "boolean", "default": false },
{ tags: Array }
}
};
// and the perstore api (based on the indexeddb api) allows you to AOP your shit kinda like this (i'm too lazy to write an example)...
// helpful property declarations
timestamp();
// not sure what this is?
// callbacks
creating({ before:poundSalt, after:emailActivationCode });
updating();
deleting();
// a private function to generate a unique salt for hashing the password, called in 'creating' callback
// testable therefore by the creating callback?
var poundSalt = function(obj) {
};
// emails an activation code
var emailActivationCode = function(obj) {
};
var forgotPassword = function(obj) {
};
// public instance attributes
this.prototype = {
// activates the user account
get active() {
},
set active() {
}
}
// views, beautiful custom finders
view('tags', { map:function(){}, reduce:function(){} });
view('popular');
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment