Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also .

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also .
Choose a Base Repository
datproject/dat
6a68/dat
ANB2/dat
Afey/dat
Ago3t1nho/dat
AlexJiaeHwang/dat
AlexandreXavier/dat
DTrejo/dat
DanteZhou/dat
FLGMwt/dat
GeoBIMpro/dat
HackG/dat
JakenHerman/dat
Klaudit/dat
LinusU/dat
MaxGfeller/dat
Mkoopajr/dat
NEPHILIM-1/dat
NortySpock/dat
Renthusiast/dat
RichardLitt/dat
SanjeebJena/dat
StarNebula/dat
WardCunningham/dat
WorldofOpenDev/dat
YanLinAung/dat
adriagalin/dat
agibsonccc/dat
ajschumacher/dat
akoenig/dat
anandthakker/dat
asd1355215911/dat
atul4mlko/dat
beaugunderson/dat
benitogf/dat
bigeasy/dat
binocarlos/dat
bmpvieira/dat
bnvk/dat
bradparks/dat
bsletten/dat
bussiere/dat
captainsafia/dat
ceejbot/dat
cesine/dat
chillypenguin/dat
chipski/dat
chrisekelley/dat
chuesler/dat
chumpalump/dat
clemsos/dat
cmpera/dat
cnwhy/dat
corbt/dat
dafyddcrosby/dat
davidguttman/dat
delkyd/dat
denismars/dat
derek-watson/dat
devildeveloper/dat
digideskio/dat
diorahman/dat
domspad/dat
dr-lab/dat
eayoungs/dat
ecoviz/dat
edsu/dat
ekg/dat
elf-pavlik/dat
engalex/dat
evanv/dat
finnp/dat
flyingzumwalt/dat
frewsxcv/dat
fureigh/dat
fusuma/dat
gabelula/dat
gabrielcury/dat
gavioto/dat
giantoak/dat
gijs/dat
gobengo/dat
groundrace/dat
hackerway/dat
hadoocn/dat
hasantayyar/dat
hexagon6/dat
hunterwayne7/dat
hyperwalle/dat
inno-v/dat
isayev/dat
jahraphael/dat
jamiepg1/dat
jarib/dat
jay3126/dat
jbenet/dat
jcblw/dat
jimjea/dat
jjjjw/dat
jkutianski/dat
joaquimserafim/dat
josephmartz/dat
joyrexus/dat
jqnatividad/dat
jronallo/dat
karissa/dat
kesla/dat
kevinsimper/dat
keynmol/dat
khayuenkam/dat
kod3r/dat
kodemill/dat
konklone/dat
lazycrazyowl/dat
lazymike/dat
lemonhall/dat
literalsands/dat
llenroc/dat
lmmx/dat
lnielsen/dat
mafintosh/dat
manjush3v/dat
marcesher/dat
marcoippolito/dat
markandrewj/dat
mathisonian/dat
mattknox/dat
mcanthony/dat
mikelehen/dat
mnjstwins/dat
modulexcite/dat
mshayeb/dat
myf/dat
nagyistoce/dat
natematias/dat
natlownes/dat
ngEdmundas/dat
nikita0208/dat
nvcexploder/dat
nvdnkpr/dat
optikfluffel/dat
paulfitz/dat
pilhokim/dat
pjbr/dat
pkafei/dat
podviaznikov/dat
pombredanne/dat
powerpak/dat
prodigeni/dat
pshken/dat
rakesh-mohanta/dat
reggi/dat
rgbkrk/dat
rjsteinert/dat
rliebi/dat
rmoorman/dat
rramdas/dat
ryancoleman/dat
saebekassebil/dat
samuell/dat
sballesteros/dat
schee/dat
schlos/dat
sethvincent/dat
sfrdmn/dat
shama/dat
silky/dat
smikes/dat
sportebois/dat
springmeyer/dat
stamhe/dat
stefanw/dat
suarasaur/dat
suensummit/dat
syncreticudon/dat
tacaswell/dat
tahoemph/dat
tforsberg/dat
timoxley/dat
tlevine/dat
todrobbins/dat
trygve-lie/dat
twistedogic/dat
twong/dat
tylerstalder/dat
vfulco/dat
vnoxygen/dat
vojnovski/dat
waqaszahoor/dat
wbteve/dat
wking/dat
xazzz/dat
xnsxns7/dat
yalamber/dat
ychaim/dat
yetone/dat
yueyingcui/dat
ywyw/dat
zawsx/opendata-db-dat
zofuthan/dat
Nothing to show
Choose a Head Repository
datproject/dat
6a68/dat
ANB2/dat
Afey/dat
Ago3t1nho/dat
AlexJiaeHwang/dat
AlexandreXavier/dat
DTrejo/dat
DanteZhou/dat
FLGMwt/dat
GeoBIMpro/dat
HackG/dat
JakenHerman/dat
Klaudit/dat
LinusU/dat
MaxGfeller/dat
Mkoopajr/dat
NEPHILIM-1/dat
NortySpock/dat
Renthusiast/dat
RichardLitt/dat
SanjeebJena/dat
StarNebula/dat
WardCunningham/dat
WorldofOpenDev/dat
YanLinAung/dat
adriagalin/dat
agibsonccc/dat
ajschumacher/dat
akoenig/dat
anandthakker/dat
asd1355215911/dat
atul4mlko/dat
beaugunderson/dat
benitogf/dat
bigeasy/dat
binocarlos/dat
bmpvieira/dat
bnvk/dat
bradparks/dat
bsletten/dat
bussiere/dat
captainsafia/dat
ceejbot/dat
cesine/dat
chillypenguin/dat
chipski/dat
chrisekelley/dat
chuesler/dat
chumpalump/dat
clemsos/dat
cmpera/dat
cnwhy/dat
corbt/dat
dafyddcrosby/dat
davidguttman/dat
delkyd/dat
denismars/dat
derek-watson/dat
devildeveloper/dat
digideskio/dat
diorahman/dat
domspad/dat
dr-lab/dat
eayoungs/dat
ecoviz/dat
edsu/dat
ekg/dat
elf-pavlik/dat
engalex/dat
evanv/dat
finnp/dat
flyingzumwalt/dat
frewsxcv/dat
fureigh/dat
fusuma/dat
gabelula/dat
gabrielcury/dat
gavioto/dat
giantoak/dat
gijs/dat
gobengo/dat
groundrace/dat
hackerway/dat
hadoocn/dat
hasantayyar/dat
hexagon6/dat
hunterwayne7/dat
hyperwalle/dat
inno-v/dat
isayev/dat
jahraphael/dat
jamiepg1/dat
jarib/dat
jay3126/dat
jbenet/dat
jcblw/dat
jimjea/dat
jjjjw/dat
jkutianski/dat
joaquimserafim/dat
josephmartz/dat
joyrexus/dat
jqnatividad/dat
jronallo/dat
karissa/dat
kesla/dat
kevinsimper/dat
keynmol/dat
khayuenkam/dat
kod3r/dat
kodemill/dat
konklone/dat
lazycrazyowl/dat
lazymike/dat
lemonhall/dat
literalsands/dat
llenroc/dat
lmmx/dat
lnielsen/dat
mafintosh/dat
manjush3v/dat
marcesher/dat
marcoippolito/dat
markandrewj/dat
mathisonian/dat
mattknox/dat
mcanthony/dat
mikelehen/dat
mnjstwins/dat
modulexcite/dat
mshayeb/dat
myf/dat
nagyistoce/dat
natematias/dat
natlownes/dat
ngEdmundas/dat
nikita0208/dat
nvcexploder/dat
nvdnkpr/dat
optikfluffel/dat
paulfitz/dat
pilhokim/dat
pjbr/dat
pkafei/dat
podviaznikov/dat
pombredanne/dat
powerpak/dat
prodigeni/dat
pshken/dat
rakesh-mohanta/dat
reggi/dat
rgbkrk/dat
rjsteinert/dat
rliebi/dat
rmoorman/dat
rramdas/dat
ryancoleman/dat
saebekassebil/dat
samuell/dat
sballesteros/dat
schee/dat
schlos/dat
sethvincent/dat
sfrdmn/dat
shama/dat
silky/dat
smikes/dat
sportebois/dat
springmeyer/dat
stamhe/dat
stefanw/dat
suarasaur/dat
suensummit/dat
syncreticudon/dat
tacaswell/dat
tahoemph/dat
tforsberg/dat
timoxley/dat
tlevine/dat
todrobbins/dat
trygve-lie/dat
twistedogic/dat
twong/dat
tylerstalder/dat
vfulco/dat
vnoxygen/dat
vojnovski/dat
waqaszahoor/dat
wbteve/dat
wking/dat
xazzz/dat
xnsxns7/dat
yalamber/dat
ychaim/dat
yetone/dat
yueyingcui/dat
ywyw/dat
zawsx/opendata-db-dat
zofuthan/dat
Nothing to show
  • 2 commits
  • 14 files changed
  • 0 commit comments
  • 1 contributor
View
3 cli.js
@@ -64,7 +64,8 @@ var dat = Dat(datPath, datOpts, function ready(err) {
}
if (typeof message === 'object') message = JSON.stringify(message)
if (!opts.argv.quiet && message) stdout.write(message.toString() + EOL)
if (datCommand.command !== 'serve' || datCommand.command !== 'listen') close()
var persist = ['serve', 'listen']
if (persist.indexOf(datCommand.command) === -1) close()
})
})
View
@@ -383,8 +383,8 @@ dat.get = function(key, opts, cb) {
return this.storage.get(key, opts, cb)
}
dat.put = function(rawDoc, buffer, opts, cb) {
return this.storage.put(rawDoc, buffer, opts, cb)
dat.put = function(key, val, opts, cb) {
return this.storage.put(key, val, opts, cb)
}
dat.delete = function(key, opts, cb) {
@@ -446,7 +446,7 @@ dat.createBlobWriteStream = function(options, doc, cb) {
if (err) return cb(err)
if (!doc.attachments) doc.attachments = {}
doc.attachments[options.filename] = blob
self.put(doc, function(err, stored) {
self.put(doc.id, doc, function(err, stored) {
cb(err, stored)
})
})
View
@@ -212,7 +212,7 @@ RestHandler.prototype.post = function(req, res) {
self.bufferJSON(req, function(err, json) {
if (err) return self.error(res, 500, err)
if (!json) json = {}
self.dat.put(json, function(err, stored) {
self.dat.put(json.id, json, function(err, stored) {
if (err) {
// if (err.conflict) return self.error(res, 409, {error: "Document update conflict. Invalid version"})
return self.error(res, 500, err)
View
@@ -1,138 +1,138 @@
var protobuf = require('protocol-buffers');
var Schema = function(storage, onReady) {
if (!(this instanceof Schema)) return new Schema(storage, onReady)
this._storage = storage
this.protobuf = null
this.columns = []
this.index = {}
this.reserved = ['id', 'change', 'version', 'deleted']
this.update(onReady)
if (!(this instanceof Schema)) return new Schema(storage, onReady)
this._storage = storage
this.protobuf = null
this.columns = []
this.index = {}
this.reserved = ['id', 'change', 'version', 'deleted']
this.update(onReady)
}
Schema.prototype.update = function(cb) {
var self = this
this._storage.getMeta('schema', {valueEncoding:'json'}, function(err, schema) {
if (err && err.notFound) err = null // grrrrr
if (err) return cb(err)
self.columns = schema || []
self.compile()
cb()
});
var self = this
this._storage.getMeta('schema', {valueEncoding:'json'}, function(err, schema) {
if (err && err.notFound) err = null // grrrrr
if (err) return cb(err)
self.columns = schema || []
self.compile()
cb()
});
}
Schema.prototype.compile = function() {
var self = this
var self = this
this.protobuf = protobuf(this.columns)
this.names = []
this.protobuf = protobuf(this.columns)
this.names = []
this.columns.forEach(function(col) {
self.names.push(col.name)
})
this.columns.forEach(function(col) {
self.names.push(col.name)
})
}
Schema.prototype.save = function(cb) {
this._storage.setMeta('schema', this.columns, {valueEncoding:'json'}, cb)
this._storage.setMeta('schema', this.columns, {valueEncoding:'json'}, cb)
}
Schema.prototype.normalize = function(cols) {
for (var i = 0; i < cols.length; i++) {
if (typeof cols[i] === 'string') cols[i] = {name:cols[i], type:'json'}
if (!cols[i]) cols[i].type = 'json'
}
return cols
for (var i = 0; i < cols.length; i++) {
if (typeof cols[i] === 'string') cols[i] = {name:cols[i], type:'json'}
if (!cols[i]) cols[i].type = 'json'
}
return cols
}
Schema.prototype.encode = function(doc) {
return this.protobuf.encode(doc)
return this.protobuf.encode(doc)
}
Schema.prototype.decode = function(buf) {
return this.protobuf.decode(buf)
return this.protobuf.decode(buf)
}
Schema.prototype.validate = function(doc) {
return this.protobuf.validate(doc)
return this.protobuf.validate(doc)
}
var mismatch = function() {
var err = new Error('Column mismatch')
err.type = 'columnMismatch'
return err
var err = new Error('Column mismatch')
err.type = 'columnMismatch'
return err
}
Schema.prototype.mergeFromObject = function(obj, cb) {
var keys = Object.keys(obj)
var updated = 0
for (var i = 0; i < keys.length; i++) {
var key = keys[i]
var val = obj[key]
if (val === null || val === undefined) continue
if (this.reserved.indexOf(key) > -1) continue
var idx = this.names.indexOf(key)
if (idx === -1) {
this.names.push(key)
this.columns.push({name:key, type:'json'})
updated++
} else {
// TODO: if type !== json type check
}
}
if (!updated) return cb()
this.compile()
this.save(cb)
var keys = Object.keys(obj)
var updated = 0
for (var i = 0; i < keys.length; i++) {
var key = keys[i]
var val = obj[key]
if (val === null || val === undefined) continue
if (this.reserved.indexOf(key) > -1) continue
var idx = this.names.indexOf(key)
if (idx === -1) {
this.names.push(key)
this.columns.push({name:key, type:'json'})
updated++
} else {
// TODO: if type !== json type check
}
}
if (!updated) return cb()
this.compile()
this.save(cb)
}
Schema.prototype.merge = function(cols, opts, cb) {
if (typeof opts === 'function') {
cb = opts
opts = null
}
var updated = 0
if (opts && opts.strict) {
for (var i = 0; i < cols.length; i++) {
var col = cols[i]
if (i >= this.columns.length) {
if (!col.type) col.type = 'json'
this.names.push(col.name)
this.columns.push(col)
updated++
} else {
if (col.type !== this.columns[i].type) return cb(mismatch())
if (col.name !== this.columns[i].name) return cb(mismatch())
}
}
} else {
for (var i = 0; i < cols.length; i++) {
var col = cols[i]
var idx = this.names.indexOf(col.name)
if (idx === -1) {
if (!col.type) col.type = 'json'
this.names.push(col.name)
this.columns.push(col)
updated++
} else {
if (col.type !== this.columns[i].type) return cb(mismatch())
}
}
}
if (!updated) return cb()
this.compile()
this.save(cb)
if (typeof opts === 'function') {
cb = opts
opts = null
}
var updated = 0
if (opts && opts.strict) {
for (var i = 0; i < cols.length; i++) {
var col = cols[i]
if (i >= this.columns.length) {
if (!col.type) col.type = 'json'
this.names.push(col.name)
this.columns.push(col)
updated++
} else {
if (col.type !== this.columns[i].type) return cb(mismatch())
if (col.name !== this.columns[i].name) return cb(mismatch())
}
}
} else {
for (var i = 0; i < cols.length; i++) {
var col = cols[i]
var idx = this.names.indexOf(col.name)
if (idx === -1) {
if (!col.type) col.type = 'json'
this.names.push(col.name)
this.columns.push(col)
updated++
} else {
if (col.type !== this.columns[i].type) return cb(mismatch())
}
}
}
if (!updated) return cb()
this.compile()
this.save(cb)
}
Schema.prototype.toJSON = function() {
return this.columns
return this.columns
}
module.exports = Schema
Oops, something went wrong.

No commit comments for this range