Commit cb727b69 authored by Administrator's avatar Administrator

generated athletes bean

parent d3117f49
import 'package:jaguar_query/jaguar_query.dart';
import 'package:jaguar_orm/jaguar_orm.dart';
part 'athlete.jorm.dart';
class Athlete {
@PrimaryKey()
String id;
String name;
int stravaId;
Athlete();
Athlete.make(this.id, this.name, this.stravaId);
static const String tableName = '_athlete';
String toString() => '$name ($id)';
}
@GenBean()
class AthleteBean extends Bean<Athlete> with _AthleteBean {
AthleteBean(Adapter _adapter) : super(_adapter);
final String tableName = 'athletes';
}
\ No newline at end of file
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'athlete.dart';
// **************************************************************************
// BeanGenerator
// **************************************************************************
abstract class _AthleteBean implements Bean<Athlete> {
final id = StrField('id');
final name = StrField('name');
final stravaId = IntField('strava_id');
Map<String, Field> _fields;
Map<String, Field> get fields => _fields ??= {
id.name: id,
name.name: name,
stravaId.name: stravaId,
};
Athlete fromMap(Map map) {
Athlete model = Athlete();
model.id = adapter.parseValue(map['id']);
model.name = adapter.parseValue(map['name']);
model.stravaId = adapter.parseValue(map['strava_id']);
return model;
}
List<SetColumn> toSetColumns(Athlete model,
{bool update = false, Set<String> only, bool onlyNonNull = false}) {
List<SetColumn> ret = [];
if (only == null && !onlyNonNull) {
ret.add(id.set(model.id));
ret.add(name.set(model.name));
ret.add(stravaId.set(model.stravaId));
} else if (only != null) {
if (only.contains(id.name)) ret.add(id.set(model.id));
if (only.contains(name.name)) ret.add(name.set(model.name));
if (only.contains(stravaId.name)) ret.add(stravaId.set(model.stravaId));
} else /* if (onlyNonNull) */ {
if (model.id != null) {
ret.add(id.set(model.id));
}
if (model.name != null) {
ret.add(name.set(model.name));
}
if (model.stravaId != null) {
ret.add(stravaId.set(model.stravaId));
}
}
return ret;
}
Future<void> createTable({bool ifNotExists = false}) async {
final st = Sql.create(tableName, ifNotExists: ifNotExists);
st.addStr(id.name, primary: true, isNullable: false);
st.addStr(name.name, isNullable: false);
st.addInt(stravaId.name, isNullable: false);
return adapter.createTable(st);
}
Future<dynamic> insert(Athlete model,
{bool cascade = false,
bool onlyNonNull = false,
Set<String> only}) async {
final Insert insert = inserter
.setMany(toSetColumns(model, only: only, onlyNonNull: onlyNonNull));
return adapter.insert(insert);
}
Future<void> insertMany(List<Athlete> models,
{bool onlyNonNull = false, Set<String> only}) async {
final List<List<SetColumn>> data = models
.map((model) =>
toSetColumns(model, only: only, onlyNonNull: onlyNonNull))
.toList();
final InsertMany insert = inserters.addAll(data);
await adapter.insertMany(insert);
return;
}
Future<dynamic> upsert(Athlete model,
{bool cascade = false,
Set<String> only,
bool onlyNonNull = false}) async {
final Upsert upsert = upserter
.setMany(toSetColumns(model, only: only, onlyNonNull: onlyNonNull));
return adapter.upsert(upsert);
}
Future<void> upsertMany(List<Athlete> models,
{bool onlyNonNull = false, Set<String> only}) async {
final List<List<SetColumn>> data = [];
for (var i = 0; i < models.length; ++i) {
var model = models[i];
data.add(
toSetColumns(model, only: only, onlyNonNull: onlyNonNull).toList());
}
final UpsertMany upsert = upserters.addAll(data);
await adapter.upsertMany(upsert);
return;
}
Future<int> update(Athlete model,
{bool cascade = false,
bool associate = false,
Set<String> only,
bool onlyNonNull = false}) async {
final Update update = updater
.where(this.id.eq(model.id))
.setMany(toSetColumns(model, only: only, onlyNonNull: onlyNonNull));
return adapter.update(update);
}
Future<void> updateMany(List<Athlete> models,
{bool onlyNonNull = false, Set<String> only}) async {
final List<List<SetColumn>> data = [];
final List<Expression> where = [];
for (var i = 0; i < models.length; ++i) {
var model = models[i];
data.add(
toSetColumns(model, only: only, onlyNonNull: onlyNonNull).toList());
where.add(this.id.eq(model.id));
}
final UpdateMany update = updaters.addAll(data, where);
await adapter.updateMany(update);
return;
}
Future<Athlete> find(String id,
{bool preload = false, bool cascade = false}) async {
final Find find = finder.where(this.id.eq(id));
return await findOne(find);
}
Future<int> remove(String id) async {
final Remove remove = remover.where(this.id.eq(id));
return adapter.remove(remove);
}
Future<int> removeMany(List<Athlete> models) async {
// Return if models is empty. If this is not done, all records will be removed!
if (models == null || models.isEmpty) return 0;
final Remove remove = remover;
for (final model in models) {
remove.or(this.id.eq(model.id));
}
return adapter.remove(remove);
}
}
# Generated by pub
# See https://www.dartlang.org/tools/pub/glossary#lockfile
# See https://dart.dev/tools/pub/glossary#lockfile
packages:
analyzer:
dependency: transitive
description:
name: analyzer
url: "https://pub.dartlang.org"
source: hosted
version: "0.34.3"
args:
dependency: transitive
description:
name: args
url: "https://pub.dartlang.org"
source: hosted
version: "1.5.2"
async:
dependency: transitive
description:
name: async
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0"
version: "2.2.0"
boolean_selector:
dependency: transitive
description:
......@@ -15,6 +29,62 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.4"
build:
dependency: transitive
description:
name: build
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
build_config:
dependency: transitive
description:
name: build_config
url: "https://pub.dartlang.org"
source: hosted
version: "0.3.2"
build_daemon:
dependency: transitive
description:
name: build_daemon
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.3"
build_resolvers:
dependency: transitive
description:
name: build_resolvers
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.3"
build_runner:
dependency: "direct dev"
description:
name: build_runner
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.3"
build_runner_core:
dependency: transitive
description:
name: build_runner_core
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.1"
built_collection:
dependency: transitive
description:
name: built_collection
url: "https://pub.dartlang.org"
source: hosted
version: "4.2.2"
built_value:
dependency: transitive
description:
name: built_value
url: "https://pub.dartlang.org"
source: hosted
version: "6.7.0"
charcode:
dependency: transitive
description:
......@@ -22,6 +92,20 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.2"
checked_yaml:
dependency: transitive
description:
name: checked_yaml
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.2"
code_builder:
dependency: transitive
description:
name: code_builder
url: "https://pub.dartlang.org"
source: hosted
version: "3.2.0"
collection:
dependency: transitive
description:
......@@ -29,6 +113,27 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.14.11"
convert:
dependency: transitive
description:
name: convert
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.1"
crypto:
dependency: transitive
description:
name: crypto
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.1+1"
csslib:
dependency: transitive
description:
name: csslib
url: "https://pub.dartlang.org"
source: hosted
version: "0.16.1"
cupertino_icons:
dependency: "direct main"
description:
......@@ -36,6 +141,20 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.2"
dart_style:
dependency: transitive
description:
name: dart_style
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.3"
fixnum:
dependency: transitive
description:
name: fixnum
url: "https://pub.dartlang.org"
source: hosted
version: "0.10.9"
flutter:
dependency: "direct main"
description: flutter
......@@ -46,6 +165,118 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
front_end:
dependency: transitive
description:
name: front_end
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.9+1"
glob:
dependency: transitive
description:
name: glob
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.7"
graphs:
dependency: transitive
description:
name: graphs
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.0"
html:
dependency: transitive
description:
name: html
url: "https://pub.dartlang.org"
source: hosted
version: "0.14.0+2"
http:
dependency: transitive
description:
name: http
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.0+2"
http_multi_server:
dependency: transitive
description:
name: http_multi_server
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0"
http_parser:
dependency: transitive
description:
name: http_parser
url: "https://pub.dartlang.org"
source: hosted
version: "3.1.3"
io:
dependency: transitive
description:
name: io
url: "https://pub.dartlang.org"
source: hosted
version: "0.3.3"
jaguar_orm:
dependency: transitive
description:
name: jaguar_orm
url: "https://pub.dartlang.org"
source: hosted
version: "2.2.6"
jaguar_orm_gen:
dependency: "direct dev"
description:
name: jaguar_orm_gen
url: "https://pub.dartlang.org"
source: hosted
version: "2.2.27"
jaguar_query:
dependency: transitive
description:
name: jaguar_query
url: "https://pub.dartlang.org"
source: hosted
version: "2.2.8"
jaguar_query_sqflite:
dependency: "direct main"
description:
name: jaguar_query_sqflite
url: "https://pub.dartlang.org"
source: hosted
version: "2.2.10"
js:
dependency: transitive
description:
name: js
url: "https://pub.dartlang.org"
source: hosted
version: "0.6.1+1"
json_annotation:
dependency: transitive
description:
name: json_annotation
url: "https://pub.dartlang.org"
source: hosted
version: "2.4.0"
kernel:
dependency: transitive
description:
name: kernel
url: "https://pub.dartlang.org"
source: hosted
version: "0.3.9+1"
logging:
dependency: transitive
description:
name: logging
url: "https://pub.dartlang.org"
source: hosted
version: "0.11.3+2"
matcher:
dependency: transitive
description:
......@@ -60,6 +291,27 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.6"
mime:
dependency: transitive
description:
name: mime
url: "https://pub.dartlang.org"
source: hosted
version: "0.9.6+3"
package_config:
dependency: transitive
description:
name: package_config
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.5"
package_resolver:
dependency: transitive
description:
name: package_resolver
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.10"
path:
dependency: transitive
description:
......@@ -73,19 +325,68 @@ packages:
name: pedantic
url: "https://pub.dartlang.org"
source: hosted
version: "1.5.0"
version: "1.7.0"
plugin:
dependency: transitive
description:
name: plugin
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.0+3"
pool:
dependency: transitive
description:
name: pool
url: "https://pub.dartlang.org"
source: hosted
version: "1.4.0"
pub_semver:
dependency: transitive
description:
name: pub_semver
url: "https://pub.dartlang.org"
source: hosted
version: "1.4.2"
pubspec_parse:
dependency: transitive
description:
name: pubspec_parse
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.5"
quiver:
dependency: transitive
description:
name: quiver
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.2"
version: "2.0.3"
shelf:
dependency: transitive
description:
name: shelf
url: "https://pub.dartlang.org"
source: hosted
version: "0.7.5"
shelf_web_socket:
dependency: transitive
description:
name: shelf_web_socket
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.3"
sky_engine:
dependency: transitive
description: flutter
source: sdk
version: "0.0.99"
source_gen:
dependency: transitive
description:
name: source_gen
url: "https://pub.dartlang.org"
source: hosted
version: "0.9.4+1"
source_span:
dependency: transitive
description:
......@@ -93,6 +394,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.5.5"
sqflite:
dependency: transitive
description:
name: sqflite
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.6+3"
stack_trace:
dependency: transitive
description:
......@@ -107,6 +415,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
stream_transform:
dependency: transitive
description:
name: stream_transform
url: "https://pub.dartlang.org"
source: hosted
version: "0.0.19"
string_scanner:
dependency: transitive
description:
......@@ -114,6 +429,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.4"
synchronized:
dependency: transitive
description:
name: synchronized
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.0+1"
term_glyph:
dependency: transitive
description:
......@@ -127,7 +449,14 @@ packages:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.4"
version: "0.2.5"
timing:
dependency: transitive
description:
name: timing
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.1+2"
typed_data:
dependency: transitive
description:
......@@ -142,5 +471,27 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.8"
watcher:
dependency: transitive
description:
name: watcher
url: "https://pub.dartlang.org"
source: hosted
version: "0.9.7+12"
web_socket_channel:
dependency: transitive
description:
name: web_socket_channel
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.15"
yaml:
dependency: transitive
description:
name: yaml
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.16"
sdks:
dart: ">=2.2.0 <3.0.0"
dart: ">=2.3.0 <3.0.0"
flutter: ">=1.2.1 <2.0.0"
name: encrateia
description: Activity tracker data analysis for Android and iOS
# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.0.0+1
version: 0.0.1
environment:
sdk: ">=2.1.0 <3.0.0"
......@@ -19,54 +9,15 @@ environment:
dependencies:
flutter:
sdk: flutter
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.2
jaguar_query_sqflite: ^2.2.10
dev_dependencies:
flutter_test:
sdk: flutter
build_runner:
jaguar_orm_gen: 2.2.27
# For information on the generic Dart part of this file, see the
# following page: https://www.dartlang.org/tools/pub/pubspec
# The following section is specific to Flutter.