Giter Site home page Giter Site logo

orm_mysql's Introduction

Hi there ๐Ÿ‘‹

Languages and Tools:

Visual Studio Code

Flutter



Anurag's github stats

Top Langs

orm_mysql's People

Contributors

cpdncristiano avatar marcelorab avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

orm_mysql's Issues

Error running flutter application

Error:

E/flutter ( 8774): [ERROR:flutter/shell/common/shell.cc(209)] Dart Error: error: import of dart:mirrors is not supported in the current Dart runtime
E/flutter ( 8774): [ERROR:flutter/runtime/dart_isolate.cc(141)] Could not prepare isolate.
E/flutter ( 8774): [ERROR:flutter/runtime/runtime_controller.cc(377)] Could not create root isolate.
E/flutter ( 8774): [ERROR:flutter/shell/common/shell.cc(492)] Could not launch engine with configuration.

Main:

Future<void> main() async {
  MySQL db = MySQL(
    host: "localhost",
    user: "root",
    password: "123",
    db: "test",
  );
  await db.init();
  runApp(MyApp());
}

table:

//The table Annotation indicates to be a table in mysql
//NOTE: You can add a different class name to your table
//@Table (name: 'table_user')

import 'package:orm_mysql/orm_mysql.dart';

@Table()
class banner_images {
  // the tables must have an id, this is the indication of the mysql primary key
  // NOTE: By default the id is auto increment.
  // to change this do: @Id (autoIncrement: false)
  @Id()
  int banner_id;

  // this annotation indicates that this column cannot be null in your database
  @NotNull()
  String banner_imbanner_type_idurl;

  int banner_type_id;

  int banner_dest_id;

  banner_images(
      {this.banner_id,
      this.banner_imbanner_type_idurl,
      this.banner_type_id,
      this.banner_dest_id});

// it is necessary to have a fromJson constructor for the orm to work
  banner_images.fromJson(Map<String, dynamic> json) {
    banner_id = json['banner_id'];
    banner_imbanner_type_idurl = json['banner_imbanner_type_idurl'];
    banner_type_id = json['banner_type_id'];
    banner_dest_id = json['banner_dest_id'];
  }

// it is necessary to have a toJson function for the orm to work
  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = Map<String, dynamic>();
    data['banner_id'] = this.banner_id;
    data['banner_imbanner_type_idurl'] = this.banner_imbanner_type_idurl;
    data['banner_type_id'] = this.banner_type_id;
    data['banner_dest_id'] = this.banner_dest_id;
    return data;
  }
}

Object:
banner_imagesRepository x = banner_imagesRepository();

Test:
x.findAll().then((value) => print(value.map((e) => e.toJson())));

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.