Open SumitBando opened 3 years ago
Similar to Issue #223
await Flight.create({ departure: "Paris", destination: "Tokyo" }); await Flight.create([{ ... }, { ... }]); ??? No specification of return value ???
Most frameworks will return either the Id from the database or the newly created model object.
MySQL driver is returning data of questionable value.
Test Program import { DataTypes, Model } from 'https://deno.land/x/denodb/mod.ts'; class Post extends Model { static table = 'posts'; static timestamps = true; static fields = { id: { primaryKey: true, autoIncrement: true }, username: {type: DataTypes.STRING /, allowNull: false /}, body: {type: DataTypes.STRING}, }; static defaults = { }; } const post = await Post.create({username:'U', body:'B'}) console.log(post) Output: Post { affectedRows: 1, lastInsertId: 1 }
lastInsertId is the id.
lastInsertId
Similar to Issue #223
await Flight.create({ departure: "Paris", destination: "Tokyo" }); await Flight.create([{ ... }, { ... }]); ??? No specification of return value ???
Most frameworks will return either the Id from the database or the newly created model object.
MySQL driver is returning data of questionable value.
Test Program import { DataTypes, Model } from 'https://deno.land/x/denodb/mod.ts'; class Post extends Model { static table = 'posts'; static timestamps = true; static fields = { id: { primaryKey: true, autoIncrement: true }, username: {type: DataTypes.STRING /, allowNull: false /}, body: {type: DataTypes.STRING}, }; static defaults = { }; } const post = await Post.create({username:'U', body:'B'}) console.log(post) Output: Post { affectedRows: 1, lastInsertId: 1 }