LiteDB - .Net, IOS, Android, Windows Phone


참조 URL
  1. http://www.litedb.org/
  2. https://github.com/mbdavid/litedb
  3. https://github.com/Ar3sDevelopment/UnitOfWork.NET.LiteDB

 



 SQLite와 비슷하게 크로스 플랫폼을 지원하고 있지만 MongoDB에서 영감을 받아 만들어진 LiteDB다. MongoDB와 같이 json 또는 bson 형식으로 데이터를 관리한다.


아래 '코드1'은 "http://www.litedb.org/"에서 나와 있는 코드로 POCO 형식을 입출력하는 예제이며, '코드2'는 POCO 클래스와 실제 물리적인 테이블간의 매칭을 시켜주는 방법을 보여주고 있다.



[코드1] CRUD


[코드2] Mapping




LiteDB V2 ( 2.0.0 )은 아래와 같은 제한 사항과 기능을 가지고 있다.


제한 사항(Limits) : 


  • Collection Name:
    • Pattern: A-Z_-0-9
    • Maxlength of 30 chars
    • Case insensitive
  • Index Name:
    • Pattern: A-Z_-0-9 (. for nested document)
    • Maxlength of 30 chars
    • Case sensitive
  • BsonDocument Key Name:
    • A-Z_-0-9
    • Case sensitive
  • FileStorage FileId:
    • Pattern: same used in file system path/file.
    • Case sensitive
  • Collections: 3000 bytes to all collections names
  • Documents per collections: UInt.MaxValue
  • FileStorage Max File Length: 2Gb per file
  • Index key size: 512 bytes after BSON serialization
  • BSON document size: 1.044.224 bytes (~1Mb = 256 pages)
  • Nested Depth for BSON Documents: 20
  • Page Size: 4096 bytes
  • DataPage Reserved Bytes: 2039 bytes (like PCT FREE)
  • IndexPage Reserved Bytes: 100 bytes (like PCT FREE)
  • Database Max Length: In theory, UInt.MaxValue * PageSize (4096) = ~ Too big!




New features in v2 - https://github.com/mbdavid/LiteDB/releases

  • Portable version: LiteDB.Core (Supports UWP 8.1/10, Xaramin.iOS and Xaramin.Android)
  • Generic data access layer - can use any Stream or you can write your own disk access layer
  • Database encription option (using password= in connection string)
  • New memory cache manager (do not consume too memory in large inserts/updates)
  • Better mapping class from your entity to BsonDocument (like Configurations in EntityFramework)
  • Better cross reference with DbRef mapping (see unit tests examples)
  • Lazy engine load (open datafile only when run a command)
  • Reduce your database size with shrink()
  • Support for Initial Size and Limit Size database (connection string)
  • Complete re-write engine classes width full debug logger
  • Complete stats about data/index usage
  • Dump file to Import/Export your data using shell commands
  • Full documentation for v2 on Wiki
  • See more examples in http://www.litedb.org/










Ionic2 + angular2 + Visual studio code - quickstart


참조 URL
  1. http://ionicframework.com/docs/v2/getting-started/
  2. http://www.gajotres.net/ionic-2-how-to-use-cordova-plugins/
  3. http://www.joshmorony.com/using-cordova-plugins-in-ionic-2-with-ionic-native/
  4. https://forum.ionicframework.com/t/ionic-2-with-ng-cordova/36103

 


아래와 같은 순서로 진행한다.

( node, npm 이 동작할 수 있도록 구성은 되어 있어야 한다.)


> npm install ionic@beta -g

> npm install cordova -g

> ionic start example tutorial --v2

> cd example

> ionic serve or ionic serve -l -a



--------------------------------------------------------------------------------------------------------------------------------


> npm install ionic@beta -g


전역으로 ionic@beta 모듈을 설치 한다.



> npm install cordova -g


전역으로 cordova를 설치 한다.



> ionic start example tutorial --v2


전역으로 받은 모듈을 통해 ionic 프로젝트를 만든다. 

example 폴더를 만들고  ionic2 버전으로 tutorial 템플릿을 가지고 만든다.




> cd example


example 폴더로 이동




> ionic serve or ionic serve -l -a


ionic 프로젝트 로컬에서 확인할 수 있도록 자체 웹 서버를 구동하여 미리보기 할 수 있도록 한다.

이렇게 실행하면 브라우저가 뜨면서 화면을 확인 할 수 있다.


[그림1] ionic serve 실행 화면





[그림2] 미리보기 화면





위와 같이 마무리가 되었다면 Visual studio code에서 폴더로 불러오면 아래와 같이 된다.


[그림3] Visual studio code에서 불러오기



 이제 부터 app > pages > hello-ionic > hello-ionic.html 파일을 열고 코드를 수정하면 바로 "그림2"에서 본 화면에서 새로 고침이 되어 즉각 확인 할 수 있다. 이제부터 Ionic2 + Angular2로 개발할 준비가 완료가 되었다.








Visual Studio Tools for Apache Cordova 개발 관련 링크


참조 URL
  1. https://cordova.apache.org/docs/en/latest/
  2. http://taco.visualstudio.com/
  3. https://taco.visualstudio.com/en-us/docs/cordova-samples/
  4. https://github.com/Microsoft/cordova-samples/tree/master/todo-angularjs
  5. http://taco.visualstudio.com/en-us/docs/create-to-do-list-app/

 


































Visual studio - ripple 사용시 에러


참조 URL
  1. http://emulate.phonegap.com/
  2. https://chrome.google.com/webstore/detail/ripple-emulator-beta/geelfhphabnejjhdalkjhgipohgpdnoc

 



 Visual Studio에서 크로스 플랫폼으로 앱을 개발할 수 있는 방법중에 Apache Cordova를 이용하여 iOS, Andriod, Windows Phone용 앱을 개발 할 수 있다. Visual studio에서 TypeScript를 선택하고 "Blank App (Apache Cordova)를 선택하여 프로젝트를 만들 수 있다.


[그림1] Blank app를 선택한 화면




 아래 그림과 같이 프로젝트가 생성을 하였다.


[그림2] 새로 만든 프로젝트



 이 상태에서 Ctrl + F5를 눌러 실행을 시켜 보면 아래와 같은 에러가 발생이 되면서 중단이 되어 확인할 수 없게 되어 있다.




에러 해결을 위해서는 레지스트리를 아래 그림과 같이 변경해줘야 한다.


HKEY_LOCAL_MACHINE\SOFTWARE\StartMenuInternet\Google Chrome의 키 값을 "Chrome"에서 "Google Chrome"로 변경"


[그림3] 레지스트리 변경





Tip! - Chrome 확장앱 설치


위와 같이 설정을 하였는데도 실행이 되지 않으면 크롬에서 아래의 주소를 통해 크롬 확장앱을 설치한다.


https://chrome.google.com/webstore/detail/ripple-emulator-beta/geelfhphabnejjhdalkjhgipohgpdnoc







 위와 같이 모두 준비가 되었다면 아래와 같은 화면을 확인할 수 있을것이다.


[그림4] 실행화면



 이제 Apache Cordova를 통해 하이브리드 앱을 개발할 수 있는 환경이 갖춰진 것이다.


















+ Recent posts