sábado, 5 de noviembre de 2022

What is sequelize.js?

 https://usecsv.com/community/sequelize-with-nodejs

What is sequelize.js?


Sequelize is a promise-based, Node.js ORM (Object-relational mapping) for Postgres, MySQL, MariaDB, SQLite and Microsoft SQL Server. It features solid transaction support, relations, eager and lazy loading, read replication, and more.

A great thing about Sequelize is that it does not care about your underlying database. You can easily switch databases by adjusting the configuration file, and your code will mostly remain the same.

svg viewer
Interaction between database and Node.js
  1. Install the relevant packages using npm or yarn.
  1. Configure your database.

You need a Sequelize instance to pass a connection URI. The authenticate() function can be used to test if the connection has been established.

Modeling your database using Sequelize is very convenient. A model in Sequelize is basically a representation of a table in your database. A Model instance contains details about the entity it represents. Every model has a name in Sequelize.

Here is a basic example of modeling the data:

viernes, 4 de noviembre de 2022

Error: : XamlC error XFC0000 : Cannot resolve type "PopupPage" when using xmlns:rg="http://rotorgames.com"

 




tkefauver commented on 9 Aug 2021 • 

I was able to fix the XamlC error and hot reload problem by:

  1. importing the Rg.Plugins.Popup .csproj and referencing the project and its dll's
  2. putting the namespace ref's back to:
    xmlns:rg="clr-namespace:Rg.Plugins.Popup.Pages;assembly=Rg.Plugins.Popup"
    xmlns:rga="clr-namespace:Rg.Plugins.Popup.Animations;assembly=Rg.Plugins.Popup"


https://github.com/rotorgames/Rg.Plugins.Popup/issues/619

martes, 1 de noviembre de 2022

Generate class from database table

https://stackoverflow.com/questions/5873170/generate-class-from-database-table

declare @TableName sysname = 'USERS'

declare @Result varchar(max) = 'public class ' + @TableName + '

{'


select @Result = @Result + '

    public ' + ColumnType + NullableSign + ' ' + ColumnName + ' { get; set; }

'

from

(

    select 

        replace(col.name, ' ', '_') ColumnName,

        column_id ColumnId,

        case typ.name 

            when 'bigint' then 'long'

            when 'binary' then 'byte[]'

            when 'bit' then 'bool'

            when 'char' then 'string'

            when 'date' then 'DateTime'

            when 'datetime' then 'DateTime'

            when 'datetime2' then 'DateTime'

            when 'datetimeoffset' then 'DateTimeOffset'

            when 'decimal' then 'decimal'

            when 'float' then 'double'

            when 'image' then 'byte[]'

            when 'int' then 'int'

            when 'money' then 'decimal'

            when 'nchar' then 'string'

            when 'ntext' then 'string'

            when 'numeric' then 'decimal'

            when 'nvarchar' then 'string'

            when 'real' then 'float'

            when 'smalldatetime' then 'DateTime'

            when 'smallint' then 'short'

            when 'smallmoney' then 'decimal'

            when 'text' then 'string'

            when 'time' then 'TimeSpan'

            when 'timestamp' then 'long'

            when 'tinyint' then 'byte'

            when 'uniqueidentifier' then 'Guid'

            when 'varbinary' then 'byte[]'

            when 'varchar' then 'string'

            else 'UNKNOWN_' + typ.name

        end ColumnType,

        case 

            when col.is_nullable = 1 and typ.name in ('bigint', 'bit', 'date', 'datetime', 'datetime2', 'datetimeoffset', 'decimal', 'float', 'int', 'money', 'numeric', 'real', 'smalldatetime', 'smallint', 'smallmoney', 'time', 'tinyint', 'uniqueidentifier') 

            then '?' 

            else '' 

        end NullableSign

    from sys.columns col

        join sys.types typ on

            col.system_type_id = typ.system_type_id AND col.user_type_id = typ.user_type_id

    where object_id = object_id(@TableName)

) t

order by ColumnId


set @Result = @Result  + '

}'


print @Result