Coder Social home page Coder Social logo

ps-microorm's Introduction

SQL-Entity

This project has for purpose to generate SQL queries based on members defined in your custom classes.

It allows you to not take in charge the SQL queries in your powershell script to lighten them.
It only supports SQL Server connection for the moment

How to configure the SQL Connection

2 methods can be used to define the SQL instance and database

Either by defining it in the code

using module .\src\Database.psm1

[Database]::SqlInstance = 'TEST-SQL\INSTDB01'
[Database]::SqlDatabase = 'Test'
[Database]::Password = ''
[Database]::Username = ''

Either by getting it from the config.json file with this code

using module .\src\Database.psm1

[Database]::loadConnectionData()

One of these 2 method should absolutely be used before trying to load data from Models
The models are using a method declared in Database who needs to know which Sql Server DBMS has to be used

How to use it ?

To have more informations on how the class management system has been thought, you can check what has been written in the following files.

  • .\src\Models\Customer.psm1
  • .\src\Models\Order.psm1

I tried to manage it to be as simple as possible
Once well parametered, you should just have to deal with 4 methods (select, insert, update and delete)

The select function can be tricky due to 'SQL.DataRow' conversion system to custom Object.
But relax, an example is provided in the Customer model

Here is also a short example of how it can be used in a script

using module .\src\Models\Customer.psm1

$c = [Customer]::new()

# Create a new Customer
$c.name = 'Test'
$c.decimal = 4.5
$c.insert()

# Update the Customer
$c.boolean = $true
$c.update()

# Delete the first customer
$c.delete()

You can also check the exemple.ps1 file at the root of the project

ps-microorm's People

Contributors

h0livier avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.