-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
accept level instances and don't create them #1
Comments
@matthewmueller maintains the leveldb adapter but I vote yes for the merge, especially on .get stuff. |
Sweet. So my thoughts:
Why don't we support both? If you pass a string in create, otherwise do not.
This is a bug due to modella changes. We should also be returning an array of modella instances when we call |
I also changed the name to keep the naming convention in the |
FYI Modella supports array instantiating... |
I don't think it should be the adapter responsibility to instantiate the db. But it's a personal "taste", and I would be willing to implement that if you really think it's the best API.
I didn't forget to implement If var through = require('ordered-through'),
level_modella.all = function(opts) {
var self = this
return this.db.createValueStream(opts).pipe(through(function (value, fn) {
fn(null, self(value))
))
} Returning an array with all the models would be crazy: imagine a |
I think in most cases you're right. but it's simple to add and it makes bootstrapping a bit simpler.
Actually haven't been keeping up with leveldb lately, but is there any concept of running a streaming query? |
yes: var stream = db.createReadStream() //createKeyStream, createValueStream and createWriteStream are also available
stream.on('data', function (data) {
console.log(data.key, '=', data.value)
})
stream.on('error', function (err) {
console.log('Oh my!', err)
})
stream.on('close', function () {
console.log('Stream closed')
})
stream.on('end', function () {
console.log('Stream closed')
}) |
Oh okay sweet. As a mental TODO, we should probably expose that on the API somehow. On Dec 2, 2013, at 4:31 PM, Sérgio Ramos [email protected] wrote:
|
@matthewmueller @rschmukler pushed the desired changes: https://github.com/ramitos/level-modella/commit/c42de78d5b35972b34c5f0e4c8328ba2fde0c01c |
I have a fork (https://github.com/ramitos/level-modella) of this repo with the following changes:
Model.get
is called, the callback value is an instantiatedModel
This allows to have a sublevel(https://github.com/dominictarr/level-sublevel / https://github.com/stagas/sublevel) for each
Model
.I also added some tests (100% coverage).
Do you want me to do a PR, or should I keep my repo as an independent fork?
The text was updated successfully, but these errors were encountered: