Git Product home page Git Product logo

lantern's Introduction

Lantern ๐Ÿ”†

Firebase Cloud Firestore's data structure definition language and code generator. Lantern lights bright future of your project.

Features

Definition Language

Have you ever been confused sharing collections / document structure in team? Or forgetting the structure by your self?

No problem. Lantern is simple data structure definition language to write down your Firestore structure.

It's easy to lean, to read, to use.

collection users {
    document User {
        string name
        array<string> attributes
        timestamp lastLogined

        collection tweets {
            document Tweet {
                string body
                reference<Tweet> referring
            }
        }
    }
}

Code Generation Toolkit

Is hard for you that writing both code for iOS and Android? Have you ever mistook spelling between source code and security rule?

Lantern has code generation toolkit. You can concentrate to using defined data structure. It can provide code for ...

Install

$ pub global activate lantern

Usage

$ lantern <your_definition_file>

Grammar

collection

collection nameOfCollection(autoId = true) {
    ...
}

collection must have name and just one document. Parameters are optional.

document

document NameOfDocument(saveCreatedDate = true) {
    ...
}

document have name and parameters (optional). And have fields and collections in body.

Fields and Types

    string                      name
    boolean                     isAdult
    integer                     level
    number                      score
    url                         blogUrl
    array<string>               appeals
    map                         history
    timestamp                   birthday
    geopoint                    lastUsedFrom
    enum Rank {free, purchased} memberRank
    enum<Rank>                  anotherRank
    reference<DocumentName>     relatedDocument
    struct<DocumentName>        embeddedDocument
    struct S { string a }       embeddedStruct
Lantern Type Firestore Type Swift Type Dart type TypeScript Type
string string String String string
boolean boolean Bool bool boolean
integer number Int int number
number number Double double number
url string URL Uri string
array<T> array [T] List<T> [T]
map map [String : Any] Map<String, dynamic> {}
timestamp timestamp Timestamp Timestamp Timestamp
geopoint geopoint GeoPoint GeoPoint GeoPoint
reference<T> reference DocumentReference (T will be omitted) DocumentRefernce (T will be omitted) DocumentRefernce (T will be omitted)
struct<T> map T (T should be Codable) T (Document) T (Document)
file map (file will be uploaded to Cloud Storage) File StorageFile File
enum{elements...} string enum (enum classes will be generated) enum(enum classes will be generated) enum(const enum of string will be generated)
enum<T> string T (T should be enum) T (T should be enum) T (T should be enum)
struct S {fields...} map S (Codable class will be generated) SModel (Model class will be generated) S (interface will be generated)

lantern's People

Contributors

kikuchy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

tacksman

lantern's Issues

Bump up dependencies versions

Hi, and thanks for the plugin!

There will be trouble for anyone wanting to use it, however, as it uses quite old dependencies of some plugins.

Because no versions of xml match >4.4.1 <5.0.0 and xml >=3.7.0 <4.4.0 depends on petitparser ^3.0.0, xml >=3.7.0 <4.4.0-โˆž or >4.4.1 <5.0.0 requires petitparser ^3.0.0.
And because xml >=4.4.0 <4.4.1 depends on petitparser ^3.1.0 and xml 4.4.1 depends on petitparser ^3.0.0, xml >=3.7.0 <5.0.0 requires petitparser ^3.0.0.
And because flutter_svg 0.18.0 depends on xml ^4.1.0 and every version of lantern depends on petitparser ^2.4.0, flutter_svg 0.18.0 is incompatible with lantern.
So, because my_app depends on both lantern 0.0.6+3 and flutter_svg 0.18.0, version solving failed.
pub get failed (1; So, because my_app depends on both lantern 0.0.6+3 and flutter_svg 0.18.0, version solving failed.)

Recommended: upgrade dependencies as you bump versions. Make it a habbit to check for versions using flutter pub outdated.

Hope you'll release an update to address it, thank you again.

parse error of array type on TypeSctiprt

I try parse,

collection tests {
    document Test(saveCreatedDate = true, saveModifiedDate = false) {
        array<file>Files
    }
}

generateed ts file is

/* tslint:disable */
import { Doc as _i0Doc, Field as _i1Field, File as _i2File } from "@1amageek/ballcap-admin"

export class Test extends _i0Doc {
    static modelName(): string {
        return "tests"
    }
    
    @_i1Field Files: [_i2File] = []
}

Error occurs Property '0' is missing in type '[]' but required in type '[any]'.ts(2741) in @_i1Field Files: [_i2File] = []

Should be parsed @_i1Field Files: _i2File[] = [] ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.