Skip to content

Commit 36ba535

Browse files
committed
Fix generator to support multiple database classes in single project + prepare new release
1 parent d4c1a7c commit 36ba535

File tree

12 files changed

+885
-14
lines changed

12 files changed

+885
-14
lines changed

NETCoreSyncServer/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 1.0.1
2+
3+
* Fix wrong link description.
4+
15
## 1.0.0
26

37
* Initial Release.

NETCoreSyncServer/NETCoreSyncServer.csproj

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@
1414
<PackageProjectUrl>https://github.com/aldycool/NETCoreSync/tree/master/NETCoreSyncServer</PackageProjectUrl>
1515
<RepositoryUrl>https://github.com/aldycool/NETCoreSync/tree/master/NETCoreSyncServer</RepositoryUrl>
1616
<PackageTags>database sync synchronization framework NETCoreApp NET5.0 Flutter</PackageTags>
17-
<PackageReleaseNotes>v1.0.0 Release Notes: Initial Release.</PackageReleaseNotes>
17+
<PackageReleaseNotes>
18+
* Fix wrong link description.
19+
</PackageReleaseNotes>
1820
<PackageRequireLicenseAcceptance>true</PackageRequireLicenseAcceptance>
19-
<Version>1.0.0</Version>
21+
<Version>1.0.1</Version>
2022
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
2123
</PropertyGroup>
2224

NETCoreSyncServer/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
| :---: | :---: | :---: |
77
| [![netcoresync_moor version](https://img.shields.io/pub/v/netcoresync_moor.svg)](https://pub.dev/packages/netcoresync_moor) | [![netcoresync_moor_generator version](https://img.shields.io/pub/v/netcoresync_moor_generator.svg)](https://pub.dev/packages/netcoresync_moor_generator) | [![Nuget](https://img.shields.io/nuget/v/NETCoreSyncServer)](https://www.nuget.org/packages/NETCoreSyncServer) |
88

9-
The server-side .NET Core framework that hosts the synchronization data middleware for Flutter clients that uses the `netcoresync_moor` package. This project is implemented in .NET 5.0 Middleware and uses WebSockets for its data communication. Visit the [netcore_sync_moor repository](https://github.com/aldycool/NETCoreSync/blob/master/netcoresync_moor) for more details.
9+
The server-side .NET Core framework that hosts the synchronization data middleware for Flutter clients that uses the `netcoresync_moor` package. This project is implemented in .NET 5.0 Middleware and uses WebSockets for its data communication. Visit the [netcoresync_moor repository](https://github.com/aldycool/NETCoreSync/blob/master/netcoresync_moor) for more details.

netcoresync_moor/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 1.0.1
2+
3+
* Provide example and shorten `pubspec.yaml` description to increase pub points.
4+
15
## 1.0.0
26

37
* Initial Release.

netcoresync_moor/example/main.dart

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
import 'dart:io' as io;
2+
import 'package:moor/moor.dart';
3+
import 'package:moor/ffi.dart';
4+
import 'package:uuid/uuid.dart';
5+
import 'package:netcoresync_moor/netcoresync_moor.dart';
6+
7+
part 'main.g.dart';
8+
9+
// The following is just an example of how to "syntactically" use the library,
10+
// technically the example won't synchronize correctly because the server-side
11+
// component needs to be configured first. For more complete example, visit the
12+
// project example on:
13+
// https://github.com/aldycool/NETCoreSync/tree/master/Samples/ServerTimeStamp/clientsample
14+
15+
@NetCoreSyncTable()
16+
class Employees extends Table {
17+
TextColumn get id =>
18+
text().withLength(max: 36).clientDefault(() => Uuid().v4())();
19+
TextColumn get name => text()();
20+
DateTimeColumn get birthday =>
21+
dateTime().clientDefault(() => DateTime.now())();
22+
23+
// these are the "synchronization" fields
24+
TextColumn get syncId =>
25+
text().withLength(max: 36).withDefault(Constant(""))();
26+
TextColumn get knowledgeId =>
27+
text().withLength(max: 36).withDefault(Constant(""))();
28+
BoolColumn get synced => boolean().withDefault(const Constant(false))();
29+
BoolColumn get deleted => boolean().withDefault(const Constant(false))();
30+
31+
@override
32+
Set<Column> get primaryKey => {
33+
id,
34+
};
35+
}
36+
37+
@UseMoor(
38+
tables: [
39+
Employees,
40+
NetCoreSyncKnowledges,
41+
],
42+
)
43+
class MyDatabase extends _$MyDatabase
44+
with NetCoreSyncClient, NetCoreSyncClientUser {
45+
MyDatabase(QueryExecutor queryExecutor) : super(queryExecutor);
46+
47+
@override
48+
int get schemaVersion => 1;
49+
50+
@override
51+
MigrationStrategy get migration => MigrationStrategy(
52+
onCreate: (Migrator m) {
53+
return m.createAll();
54+
},
55+
);
56+
}
57+
58+
void main() async {
59+
final myDatabase = MyDatabase(LazyDatabase(() async {
60+
final file = io.File("my_database_file.db");
61+
return VmDatabase(file, logStatements: true);
62+
}));
63+
await myDatabase.netCoreSyncInitialize();
64+
65+
// The server-side setup needs to be configured first, or else the
66+
// synchronization will fail. For more complete example, visit the project
67+
// example on:
68+
// https://github.com/aldycool/NETCoreSync/tree/master/Samples/ServerTimeStamp/clientsample
69+
await myDatabase.netCoreSyncSynchronize(
70+
url: "wss://localhost:5001/netcoresyncserver");
71+
}

0 commit comments

Comments
 (0)