Opened 12 years ago

Last modified 7 years ago

#3127 closed enhancement

[] add Schema API — at Initial Version

Reported by: skinner Owned by: anonymous
Priority: low Milestone: future
Component: Data Version: 0.9
Keywords: needsreview Cc: Kris Zyp
Blocked By: Blocking:


Sometime in the future, when we have more time, we should consider adding a Schema API.

Here's some brainstorming about what might look like:

	//	summary:
	//		This is an abstract API that data provider implementations conform to.
	//		This file defines methods signatures and intentionally leaves all the
	//		methods unimplemented.

	getFeatures: function(){
		//	summary: 
		//		See
		return {
			 '': true,
			 '': true

	getItemClass: function(/* item */ item){
		//	summary:
		//		Given an item, this method returns the item-class of the item.  
		//		For example, in a library database there might be item-classes 
		//		like Book, Author, and Movie.  Or in an LDAP datastore, 
		//		different items might belong to item-classes like Person, 
		//		Group, Organization, and Country.
		//		An item-class may be represented by a string, like "Book"; or
		//		by object with information about that item-class,
		//		like {name:"Book", attributes:["title", "author"]}; or by a 
		//		special item that holds all the information about that item-class.
		//	examples:
		//		var itemClass = store.getItemClass(item);
		//		var movie = store.getItemClass(starWars);
		//		var book = store.getItemClass(theHobbit);
		//		var person = store.getItemClass(jrrTolkien);
		return itemClass; // itemClass
	getItemClasses: function(){
		//	summary:
		//		Returns an array with all the item-classes that may occur in
		//		this datastore.
  		//	examples:
		//		var array = store.getItemClasses(); // [movie, book, person]
		return array; // Array of item-classes

	getAttributesOfItemClass: function(/* itemClass */ itemClass){
		//	summary:
		//		Returns an array with the attributes that this class of item has.
		//	examples:
		//		var array = store.getAttributesOfItemClass(book); // [title, author]
		//		var array = store.getAttributesOfItemClass(person); // [name, dateOfBirth]
		return array; // Array of attributes
	getTypeOfAttribute: function(/* attribute || attribute-name-string */ attribute){
		//	summary:
		//		Returns the type that an attribute normally holds.  The type
		//		may be a literal type like String or Date, or an item-class like
		//		Book or Person.
		//	issue:
		//		At some point we might also want more nuanced types for literals.
		//		We might want to specify JavaScript number literals like 
		//		"Number:int" or "Number:float", or string literals like 
		//		"String:URL".  Or, more importantly, we may need to be able to
		//		interoperate with existing databases without losing native type
		//		information.  When talking to an RDBMS, it may be important to
		//		for an app's user interface to be able to distinguish between
		//		"String:varchar(255)" and a "String:text".  Or, when talking to
		//		an XML database, it may be important to be able to use any of 
		//		the dozens of XML Schema datatypes like "float", "unsignedInt", 
		//		"year", and "uriReference".
		//	examples:
		//		var type = store.getTypeOfAttribute(title); // String
		//		var type = store.getTypeOfAttribute(publicationDate); // Date
		//		var type = store.getTypeOfAttribute(author); // Person
		return type; // Object

Change History (0)

Note: See TracTickets for help on using tickets.