我正在尝试使用 Bogus 库在 .Net Core 2.1 应用程序中生成随机种子数据,并使用 EF Core 进行数据管理。
我有一个名为 Company 的对象,它拥有一个地址;这是一对一的关系。
公司模式:
public class Company
{
public long Id { get; set; }
[Required]
public Address Address { get; set; }
public string Phone { get; set; }
public string Email { get; set; }
public string Website { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
地址型号:
public class Address : IValidatableObject
{
public long Id { get; set; }
public string Street1 { get; set; }
public string Street2 { …Run Code Online (Sandbox Code Playgroud) 我使用 Drizzle 作为 Typescript 后端,为一些 API 端点提供服务。我的数据库是 Postgresql,有一个 JSON 列。
export const transactions = pgTable("transactions", {
id: serial("id").primaryKey(),
my_json: json('my_json')
});
Run Code Online (Sandbox Code Playgroud)
我如果尝试从 supabase 表编辑器存储{"hello":"world"},这就是我得到的:
如果我尝试使用 TS/Drizzle 插入我的 {"hello":"world"} ,这就是我得到的:
不知怎的,我找不到设置或方法让 drizzle 将其存储为真正的 JSON 对象而不是它的字符串版本。