ObjectDB는 Dart 및 Flutter 애플리케이션을 위한 지속 가능한 내장형 문서 기반 NoSQL 데이터베이스입니다. JSON과 유사한 문서를 사용하여 로컬 데이터 저장을 가능하게 하며 별도의 서버 없이 완전한 CRUD 작업을 지원합니다. 단순성과 성능을 위해 설계되어 모바일, 웹, 데스크톱 등 주요 모든 플랫폼에서 작동합니다. ObjectDB는 데이터 지속성과 스키마 진화를 자동으로 처리하므로 오프라인 우선 앱에 신뢰할 수 있는 로컬 저장소가 필요한 경우 이상적입니다.
사용 사례
오프라인 우선 모바일 앱
Flutter 앱에서의 로컬 데이터 저장
크로스 플랫폼 데이터 지속성
로컬 데이터베이스를 사용한 프로토타이핑
간단한 문서 기반 데이터 모델링
주요 기능
임베디드 및 제로 구성
모든 플러터 플랫폼을 지원합니다
JSON 유사 문서 저장
자동 지속성
스키마 없는 설계
적합한 대상
경량 로컬 저장소를 찾는 개발자
오프라인 기능이 필요한 앱
외부 데이터베이스 종속성 회피 프로젝트
빠른 프로토타이핑
소규모에서 중규모 데이터 세트
고려 사항
대규모 또는 고병렬 시나리오에 적합하지 않습니다
완전한 SQL 데이터베이스에 비해 쿼리 기능이 제한적
원격 서버와의 내장 동기화 없음
단일 장치 사용 사례에 가장 적합
원본 README
연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.
ObjectDB
Persistent embedded document-oriented NoSQL database for Dart and Flutter. 100% Dart.
If you notice any bugs you can create an issue on GitHub. You're also welcome to contribute using pull requests. Please open an issue before spending time on any pull request.
Future<void> db.close() closes database (should be awaited to ensure all queries have been executed)
find
Future<List<Map>> db.find(Map query) List with all matched documents
Future<Map> db.first(Map query) first matched document
Future<Map> db.last(Map query) last matched document
insert
Future<ObjectId> db.insert(Map document) insert single document
Future<List<ObjectId>> db.insertMany(List<Map> documents) insert many documents
update
Future<int> db.update(Map query, Map changes, [bool replace = false]) update documents that mach query with changes (optionally replace whole document)
remove
Future<int> db.remove(Map query) remove documents that match query
Query
// Match fields in subdocuments
{Op.gte: {
'birthday.year': 18
}}
// or-operator
{Op.or: {
'active': true,
Op.inList: {'group': ['admin', 'moderator']}
}}
// not equal to
{Op.not: {'active': false}}
NOTE Querying arrays is not supportet yet.
Operators
Logical
and (default operator on first level)
or
not
Comparison
lt, lte: less than, less than or equal
gt, gte: greater than, greater than or equal
inList, notInList: value in list, value not in list
Modify
set: set value
max, min: set max or min int value
increment, multiply: increment/multiply by
unset: unset key/value
rename: rename key
todo: push / pull
{Op.set: {'path.to.key': 'value'}} // set entry['path']['to']['key'] = 'value' (path will be created if not exists)
{Op.max: {'path.to.key': 200}} // set value 200 if value is greater than 200
{Op.min: {'path.to.key': 200}} // set value 200 if value is smaller than 200
{Op.increment: {'path.to.key': -5}} // increment value by negative 5
{Op.multiply: {'path.to.key': 2}} // multiply value by 2
{Op.unset: {'path.to.key': true}} // unset key/value at entry['path']['to']['key'] if exists
{Op.rename: {'path.to.key': 'new_key'}} // new value will be at entry['path']['to']['new_key']
db.update({
'age': RegExp('[18-20]'),
Op.gt: {'duration': 500},
}, {
Op.max: {'stats.score': 100},
Op.increment: {'stats.level': -5},
});