Created
July 19, 2016 19:28
-
-
Save otaviosoares/8de65fc4cec1ac89cb66786a913ec41c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var entity = seneca.make('cliente') | |
entity.name = 'Otavio' | |
entity.save$(function(err) { | |
console.log('saved') | |
}) | |
// Collection cliente | |
//id name | |
//1 Otavio | |
entity.load$({name: 'Otavio', function(err, entity) { | |
console.log('loaded the entity', entity) | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var sourced = seneca.make_sourced('cliente') | |
sourced.digest('name-added', {name: 'Otavio'}) | |
sourced.commit() | |
// Collection client events | |
//id event version data | |
//1 name-added 1 {name: 'Otavio'} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var cliente = new Cliente() | |
user.addName({name: 'Otavio'}) | |
sourcedRepository.commit(cliente, function() { | |
// raises name-added | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Cliente () { | |
this.name = '' | |
Sourced.apply(this, arguments) | |
} | |
util.inherits(Cliente, Sourced) | |
Cliente.prototype.addName = function (param) { | |
this.name = param.name | |
this.digest('name-added', param) | |
this.enqueue('name-added', param, this) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment