Javascript EAV example

by Chase Wilson

JavaScript

/*
Entities:
-Image
-Document

Attribute Types:
- String
- Image
- Dropdown
- Boolean

*/

entities = {
    Image = {
        attributes: [ "hero" ,"thumb" ,"title" ]
    }
};

attributes = {
    "hero":{
        type:"image"
    },
    "thumb":{
        type:"image"
    },
    "title":{
        type:"string"
    }
};

var Entity = new Class({
    initialize: function(entity,options){
        
    }
});

var Attribute =  new Class({
    key: '',
    values: [],
    initialize: function(key, options){
    
    }
});

Attribute.String = new Class({
    Extends: Attribute
});

Attribute.Image = new Class({
    Extends: Attribute,
    source: ""
});

Attribute.Boolean = new Class({
    Extends: Attribute
});

Attribute.Dropdown = new Class({
    Extends: Attribute
});
  

var Value = new Class({
    initialize: function(){
        
    }
});