BedquiltDB PostgreSQL 扩展 项目简介
BedquiltDB 是一款开源的PostgreSQL扩展,专门用于支持jsonb数据类型的存储,并且提供相应的开放API。BedquiltDB 旨在为开发人员提供一种功能强大的工具,在项目的早期阶段,用于处理松散结构化的数据。优点:简单开放的API支持所有编程语言支持所有SQL语句,包括约束容易从"loose schema" 模式切换到 "well defined schema"而不需要改变数据库平台。示例代码:Pythonimport pybedquilt
bq = pybedquilt.BedquiltClient(dbname='bedquilt_test')
projects = bq['projects']
projects.add_constraints({
'description': {'$required': 1,
'$notnull': 1,
'$type': 'string'},
'tags': {'$required': 1,
'$type': 'array'}
})
projects.insert({
'_id': "BedquiltDB",
'description': "A ghastly hack.",
'quality': "pre-alpha",
'tags': ["json", "postgres", "api"]
})
early_projects = projects.find(
{'quality': 'pre-alpha'})
api_projects = projects.find(
{'tags': ['api']})
cool_project = projects.find_one_by_id('BedquiltDB')Node.jsvar BedquiltClient = require('bedquilt').BedquiltClient;
BedquiltClient.connect('localhost', function(err, client) {
var tools = client.collection('tools');
tools.find({type: 'blunt'}, function(err, results) {
console.log(results);
});
});SQLselect bq_insert(
'orders',
'{"_id": "2001515",
"customerId": "117176",
"items": ["orange_coat", "socks", "plastic_teeth"]}'
);
select bq_find(
'orders',
'{"customerId": "220011",
"items": ["socks"]}'
);
select bq_remove_one(
'orders',
'{"_id": "4401515"}'
);
bq = pybedquilt.BedquiltClient(dbname='bedquilt_test')
projects = bq['projects']
projects.add_constraints({
'description': {'$required': 1,
'$notnull': 1,
'$type': 'string'},
'tags': {'$required': 1,
'$type': 'array'}
})
projects.insert({
'_id': "BedquiltDB",
'description': "A ghastly hack.",
'quality': "pre-alpha",
'tags': ["json", "postgres", "api"]
})
early_projects = projects.find(
{'quality': 'pre-alpha'})
api_projects = projects.find(
{'tags': ['api']})
cool_project = projects.find_one_by_id('BedquiltDB')Node.jsvar BedquiltClient = require('bedquilt').BedquiltClient;
BedquiltClient.connect('localhost', function(err, client) {
var tools = client.collection('tools');
tools.find({type: 'blunt'}, function(err, results) {
console.log(results);
});
});SQLselect bq_insert(
'orders',
'{"_id": "2001515",
"customerId": "117176",
"items": ["orange_coat", "socks", "plastic_teeth"]}'
);
select bq_find(
'orders',
'{"customerId": "220011",
"items": ["socks"]}'
);
select bq_remove_one(
'orders',
'{"_id": "4401515"}'
);