snapmongo
An air-backend (db-less) solution using static json snapshot files. Inspired by Minimongo of Meteor.
CAUTION!: This package is yet experimental.
Preface
Snapmongo provides remote storage just using static json files. Provides a list and documents like Minimongo does. Howerver, it is not automatically refreshed but more static and public since it is served by just json files. Basically it is not authenticated but still http server side authentication could be done. It can be used in dynamic page generating static blogs as a pseudo back-end.
Snapmongo는 스태틱 파일을 이용한 원격 스토리지를 제공함. Minimongo처럼 list 와 document 를 제공하지만, 자동으로 갱신되진 않음. 기본적으로 file 이기 때문에 인증은 없지만 웹서버 차원의 인증은 가능할 것임. 의사 backend 로써 static blog라도 동적 페이지를 생성할 수 있음.
Snapmongoはスタティックファイルを用いてリモートストレージを提供する。 Minimongoのようにリストとドキュメントなどを提供するが、自動では更新されない。 基本的にファイルを使うため、認証されないが、ウェブサーバー上の認証を使えるはず。 疑似バックエンドとして静的ブログでも動的ページが生成できる。
Todos
- Add client side data overriding which is like modifying.
- Add generating snapshots as json files to update the source json files.
- Add query support in find.
- Add local storage caching with
lscache
.
Usage
npm install snapmongo
import Snapmongo from 'snapmongo'
Snapmongo.config({ base: '/assets/json/', ext: '.json' });
const blogs = new Snapmongo('blogs');
blogs.find().then(list => console.log(list, list.total));
blogs.findOne(1).then(item => console.log(item));
Sample Json
index.json
file
Single /assets/json/blogs/index.json
{
"meta": {
"total": 2,
"fields": [ "title", "preview", "creationTime" ],
"detailFields": [ "markDown" ]
},
"list": {
"2": {
"title": "Hello2",
"preview": "The second blog Hi there",
"creationTime": 1500077896308
},
"1": {
"title": "Hello1",
"preview": "The first blog Hi there",
"creationTime": 1500027896308
}
}
"details": {
"2": {
"markDown": "## The second blog data\nNothing here"
},
"1": {
"markDown": "## The first blog\n Hi there, this is the first article.\nSee you next time."
}
}
}
Multiple files
/assets/json/blogs/index.json
{
"meta": {
"total": 4,
"nextList": "list1501765968589",
"fields": [ "title", "preview", "creationTime" ],
"detailFields": [ "markDown" ]
},
"list": {
"4": {
"_detal": "",
"title": "Hello",
"preview": "The fourth blog Hi there",
"creationTime": 1500197896308
},
"3": {
"_detal": "",
"title": "Hello",
"preview": "The third blog Hi there",
"creationTime": 1500097896308
}
},
"details": {
"4": {
"markDown": "## The fourth blog data\nNothing here"
},
"3": {
"markDown": "## The third blog\n Hi there, this is the first article.\nSee you next time."
}
}
}
/assets/json/blogs/list1501765968589.json
{
"meta": {
},
"list": {
"2": {
"_detal": "detail1501765968589",
"title": "Hello2",
"preview": "The second blog Hi there",
"creationTime": 1500077896308
},
"1": {
"_detal": "detail1501765968589",
"title": "Hello1",
"preview": "The first blog Hi there",
"creationTime": 1500027896308
}
}
}
/assets/json/blogs/detail1501765968589.json
{
"meta": {
},
"details": {
"2": {
"markDown": "## The second blog data\nNothing here"
},
"1": {
"markDown": "## The first blog\n Hi there, this is the first article.\nSee you next time."
}
}
}
Milestone
- Support multiple remotes and make overrides applicable to remote also
Environment
node v4 or higher
History
2017-12-24
updated to v0.2.3
Has an upate on the local storage sttructure.
snap:overrides:lists
will be updated snap:overrides:list
with stripping [] to become an object.
2017-11-01
Updated to v0.2.2 Addd lscache to cache
2017-09-03
Updated to v0.2.1 Supports insert/update/dump
2017-08-06
Updated to v0.1.0
Has some breaking changes. Does not use callbacks any more. Just have created documentation;) Please let me know if any hassles arround this changes.
2016-06-??
initial release
Demo
The author writing a blog with Snapmongo. Please have a look if you are interested.