생성
db.defaults({ topic: [], author: []}).write();
db.get('author').push({
id:1,
name:'A',
profile:'developer'
}).write();
이렇게 write로 닫아줘야 한다
db.get('topic').push({
id:1,
title:'lowdb',
description:'lowdb is...'
author:1
}).write();
db.get('topic').push({
id:2,
title:'mysql',
description:'mysql is...'
author:1
}).write();
조회
console.log(db.get('topic').value());
하면 topic의 값들이 나온다
필요한 정보만 가져오고 싶을 때
console.log(db.get('topic').find({title:'lowdb', author:1}).value());
이런식으로 find()를 사용하면 된다
.sortBy('views') 는 정렬이고
.take(5) 는 MySQL의 limit 기능과 같다 몇개까지만 출력
.size() 는 몇개인지 알고싶을 때 사용
수정
db.get('topic')
.find({id:2})
.assign({title:'MySQL & MAriaDB'})
.write();
삭제
db.get('topic')
.remove({id:2})
.write();