@@ -13,16 +13,16 @@ public partial struct CustomStruct
13
13
}
14
14
15
15
[ SpacetimeDB . Type ]
16
- public partial struct CustomClass
16
+ public partial class CustomClass
17
17
{
18
18
public const int IGNORE_ME = 0 ;
19
19
public static readonly string IGNORE_ME_TOO = "" ;
20
- public int IntField ;
21
- public string StringField ;
20
+ public int IntField = 0 ;
21
+ public string StringField = "" ;
22
22
}
23
23
24
24
[ StructLayout ( LayoutKind . Auto ) ]
25
- public partial struct CustomClass
25
+ public partial class CustomClass
26
26
{
27
27
public int IgnoreExtraFields ;
28
28
}
@@ -44,7 +44,8 @@ public partial class PrivateTable { }
44
44
[ SpacetimeDB . Table ]
45
45
public partial struct PublicTable
46
46
{
47
- [ SpacetimeDB . Column ( ColumnAttrs . PrimaryKeyAuto ) ]
47
+ [ SpacetimeDB . AutoInc ]
48
+ [ SpacetimeDB . PrimaryKey ]
48
49
public int Id ;
49
50
50
51
public byte ByteField ;
@@ -81,18 +82,18 @@ public partial struct PublicTable
81
82
public static partial class Reducers
82
83
{
83
84
[ SpacetimeDB . Reducer ]
84
- public static void InsertData ( PublicTable data )
85
+ public static void InsertData ( ReducerContext ctx , PublicTable data )
85
86
{
86
- data . Insert ( ) ;
87
+ ctx . Db . PublicTable . Insert ( data ) ;
87
88
Log . Info ( "New list" ) ;
88
- foreach ( var item in PublicTable . Iter ( ) )
89
+ foreach ( var item in ctx . Db . PublicTable . Iter ( ) )
89
90
{
90
91
Log . Info ( $ "Item: { item . StringField } ") ;
91
92
}
92
93
}
93
94
94
95
[ SpacetimeDB . Reducer ]
95
- public static void ScheduleImmediate ( PublicTable data )
96
+ public static void ScheduleImmediate ( ReducerContext ctx , PublicTable data )
96
97
{
97
98
VolatileNonatomicScheduleImmediateInsertData ( data ) ;
98
99
}
@@ -107,7 +108,7 @@ public static partial class AndClasses
107
108
[ SpacetimeDB . Reducer ( "test_custom_name_and_reducer_ctx" ) ]
108
109
public static void InsertData2 ( ReducerContext ctx , PublicTable data )
109
110
{
110
- data . Insert ( ) ;
111
+ ctx . Db . PublicTable . Insert ( data ) ;
111
112
}
112
113
}
113
114
}
@@ -122,7 +123,7 @@ public partial struct SendMessageTimer
122
123
}
123
124
124
125
[ SpacetimeDB . Reducer ]
125
- public static void SendScheduledMessage ( SendMessageTimer arg )
126
+ public static void SendScheduledMessage ( ReducerContext ctx , SendMessageTimer arg )
126
127
{
127
128
// verify that fields were auto-added
128
129
ulong id = arg . ScheduledId ;
@@ -133,10 +134,12 @@ public static void SendScheduledMessage(SendMessageTimer arg)
133
134
[ SpacetimeDB . Reducer ( ReducerKind . Init ) ]
134
135
public static void Init ( ReducerContext ctx )
135
136
{
136
- new SendMessageTimer
137
- {
138
- Text = "bot sending a message" ,
139
- ScheduledAt = ctx . Time . AddSeconds ( 10 ) ,
140
- } . Insert ( ) ;
137
+ ctx . Db . SendMessageTimer . Insert (
138
+ new SendMessageTimer
139
+ {
140
+ Text = "bot sending a message" ,
141
+ ScheduledAt = ctx . Time . AddSeconds ( 10 ) ,
142
+ }
143
+ ) ;
141
144
}
142
145
}
0 commit comments