cpdncristiano / orm_mysql Goto Github PK
View Code? Open in Web Editor NEWLicense: BSD 3-Clause "New" or "Revised" License
License: BSD 3-Clause "New" or "Revised" License
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())));
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.