firesharkstudios / butterfly-server Goto Github PK
View Code? Open in Web Editor NEWThe Everything is Real-Time C# Backend for Single Page Applications
License: Mozilla Public License 2.0
The Everything is Real-Time C# Backend for Single Page Applications
License: Mozilla Public License 2.0
I'm trying to run the Database example. I use a SqlServer but when i try to do the UpdateAndCommitAsync() an execption throw up.
// This will echo multiple Update data events to the Console because it impacts multiple records in the resultset
// Yes, that's pretty cool :)
Console.WriteLine("Updating user name to 'Mr. Spongebob'");
await database.UpdateAndCommitAsync("users", new
{
id = spongebobId,
name = "Mr. Spongebob"
});
await Task.Delay(500);
This is the stack trace.
at Butterfly.SqlServer.SqlServerDatabase.ExecuteCommandAsync[T](Func`2 query, String executableSql, Dictionary`2 executableParams) in C:\Users\marcoc\Desktop\butterfly-server-dotnet-master\Butterfly.SqlServer\SqlServerDatabase.cs:line 268
at Butterfly.SqlServer.SqlServerDatabase.DoSelectRowsAsync(String executableSql, Dictionary`2 executableParams, Int32 limit) in C:\Users\marcoc\Desktop\butterfly-server-dotnet-master\Butterfly.SqlServer\SqlServerDatabase.cs:line 73
at Butterfly.Core.Database.Dynamic.DynamicView.GetImpactedRecordsAsync(KeyValueDataEvent keyValueDataEvent) in C:\Users\marcoc\Desktop\butterfly-server-dotnet-master\Butterfly.Core\Database\Dynamic\DynamicView.cs:line 252
at Butterfly.Core.Database.Dynamic.DynamicViewSet.StoreImpactedRecordsInDataEventTransaction(TransactionState transactionState, DataEventTransaction dataEventTransaction) in C:\Users\marcoc\Desktop\butterfly-server-dotnet-master\Butterfly.Core\Database\Dynamic\DynamicViewSet.cs:line 115
at Butterfly.Core.Database.Dynamic.DynamicViewSet.ProcessUncommittedDataEventTransactionAsync(DataEventTransaction dataEventTransaction) in C:\Users\marcoc\Desktop\butterfly-server-dotnet-master\Butterfly.Core\Database\Dynamic\DynamicViewSet.cs:line 100
at Butterfly.Core.Database.BaseDatabase.PostDataEventTransactionAsync(TransactionState transactionState, DataEventTransaction dataEventTransaction) in C:\Users\marcoc\Desktop\butterfly-server-dotnet-master\Butterfly.Core\Database\BaseDatabase.cs:line 147
at Butterfly.Core.Database.BaseTransaction.CommitAsync() in C:\Users\marcoc\Desktop\butterfly-server-dotnet-master\Butterfly.Core\Database\BaseTransaction.cs:line 258
at Butterfly.Core.Database.BaseDatabase.UpdateAndCommitAsync(String updateStatement, Object vars) in C:\Users\marcoc\Desktop\butterfly-server-dotnet-master\Butterfly.Core\Database\BaseDatabase.cs:line 257
at ConsoleApp1.Program.Run(IDatabase database) in c:\users\marcoc\source\repos\ConsoleApp1\ConsoleApp1\Program.cs:line 151
Hello,
I'd like to use Butterfly in a new project, where I have to display a report from data stored in a SQLite database. However, the web site will use jQuery with ASP.NET Core MVC, so I'm not sure how to add the Butterfly JavaScript libraries to the jQuery side.
I was able to find samples here in GitHub and on the Internet where they use Angular and npm to do that, but that is not my case.
Is there a way to accomplish this? Thanks for your help on this.
Regards,
Jorge
thanks for your great work.
The MySqlTransaction code uses ExecuteNonQueryAsync
, etc.. It's a long-standing bug in MySql.Data (bug 70111) that async I/O is not implemented correctly; thus all these methods will actually run synchronously. (See also here and here on Stack Overflow.)
To fix this, you could switch to https://github.com/mysql-net/MySqlConnector, an OSS replacement for MySql.Data that supports true asynchronous I/O. If you're interested in this, I'd be happy to open a PR.
DB Created as:
_database = new Butterfly.Core.Database.Memory.MemoryDatabase();
...
await _database.CreateFromSqlAsync(
@"CREATE TABLE event_store(
Id BIGINT AUTO_INCREMENT,
Timestamp DATETIME,
TableId CHAR(36),
Players TEXT,
Memo TEXT,
GuessPosition INT,
PRIMARY KEY (Id),
INDEX byTableId(TableId),
INDEX byTableIdAndTimestamp(TableId, Timestamp)
);"
);
Simple Dump()
method
private void Dump()
{
var selectTask = _database.SelectRowsAsync("select Id, Timestamp, TableId, Players, Memo, GuessPosition from event_store order by Id desc");
foreach (var record in selectTask.Result)
{
Log.Info(JsonUtil.Serialize(record));
}
}
Example Output:
2019-05-08 09:03:36,383 INFO [9] - {"Id":0,"Timestamp":"2019-05-08 16:03:14","TableId":"fc3897e4-9f40-4300-b9c3-a05f73ae85e1","Players":"[]","Memo":"[]","GuessPosition":0}
2019-05-08 09:03:36,385 INFO [9] - {"Id":1,"Timestamp":"2019-05-08 16:03:29","TableId":"fc3897e4-9f40-4300-b9c3-a05f73ae85e1","Players":"[{\"ScreenName\":\"someblock\",\"SessionId\":\"session-1\"}]","Memo":"[]","GuessPosition":0}
2
Expected to see record with Id
1 first.
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.