Code Monkey home page Code Monkey logo

gorm's Introduction

Godot4.0 ORM

GORM Plugins/Setup   
GrimmJSON Plugin (Local data management, good for local save systems)
  • Configuration:
  $GORM.Configure($GORM/GrimmJSON, {}, {
	"ExampleCollection":{
	  "example_default_value":0,
	}
  })

  

SQLite Plugin ** Requires https://github.com/2shady4u/godot-sqlite
  • Configuration:
  $GORM.Configure($GORM/SQLite, {}, {
	"ExampleCollection":{
	  "example_default_value":0,
	}
  })

  

(WIP) PostgreSQL Plugin

  

(paused) MongoDBAtlas DataAPI Plugin (https://cloud.mongodb.com/) ** Disclaimer, you have to manage your collections via Atlas as the API restricts this action

** Disclaimer, this plugin is a WIP and not done yet.

  • Base URL: image

  • Data Source: image

  • Configuration:

  $GORM.Configure($GORM/MongoDBAtlas,
  {
		"api_key":"your_api_key",
	"base_url":"your_base_url",
	"data_source": "your_data_source",
	"database": "your_database",
  },
  {
	"ExampleCollection":{
	  "example_default_value":0,
	}
  })

  

Godot4.0 ORM CRUD Operations

Table of Contents

Create

To add new records to your collection, you can use the Create operation.

Syntax:

$GORM.Create("CollectionName", {"field1": value1, "field2": value2})

Example:

$GORM.Create("Users", {"name": "John", "age": 30})

Read

The Read operation helps you to retrieve records based on certain conditions.

Syntax:

$GORM.Read("CollectionName", {"field__filter_type": value})

Example:

$GORM.Read("Users", {"name__icontains": "oh"})

Update

The Update operation allows you to modify existing records in your collection.

Syntax:

$GORM.Update("CollectionName", {"field1": new_value1}, {"field__filter_type": value})

Example:

$GORM.Update("Users", {"age": 31}, {"name__exact": "John"})

Delete

The Delete operation helps you remove records from your collection.

Syntax:

$GORM.Delete("CollectionName", {"field__filter_type": value})

Example:

$GORM.Delete("Users", {"age__lt": 18})

CreateCollection

The CreateCollection operation allows you to create a new collection.

Syntax:

$GORM.CreateCollection("NewCollectionName")

Example:

$GORM.CreateCollection("Cars")

DeleteCollection

The DeleteCollection operation allows you to delete an existing collection.

Syntax:

$GORM.DeleteCollection("CollectionName")

Example:

$GORM.DeleteCollection("Cars")
Godot4.0 ORM Filter Types

Table of Contents

exact

Checks for an exact match.

Example:

$GORM.Read("ExampleCollection", {"name__exact": "John"})

iexact

Case-insensitive exact match.

Example:

$GORM.Read("ExampleCollection", {"name__iexact": "john"})

contains

Checks if the field contains the given string.

Example:

$GORM.Read("ExampleCollection", {"name__contains": "oh"})

icontains

Case-insensitive containment check.

Example:

$GORM.Read("ExampleCollection", {"name__icontains": "oh"})

gt

Greater than; works with numbers.

Example:

$GORM.Read("ExampleCollection", {"age__gt": 30})

gte

Greater than or equal to; works with numbers.

Example:

$GORM.Read("ExampleCollection", {"age__gte": 30})

lt

Less than; works with numbers.

Example:

$GORM.Read("ExampleCollection", {"age__lt": 30})

lte

Less than or equal to; works with numbers.

Example:

$GORM.Read("ExampleCollection", {"age__lte": 30})

in

Checks if the field value is in the given list.

Example:

$GORM.Read("ExampleCollection", {"world_state__in": ["started", "ended", "ending"]})

range

Checks if the field value falls within a given range.

Example:

$GORM.Read("ExampleCollection", {"age__range": [30, 40]})

isnull

Checks if the field value is null or not.

Example:

$GORM.Read("ExampleCollection", {"email__isnull": true})

regex

Checks if the field value matches the regular expression.

Example:

$GORM.Read("ExampleCollection", {"name__regex": "^Jo"})

iregex

Case-insensitive regular expression match.

Example:

$GORM.Read("ExampleCollection", {"name__iregex": "^jo"})

startswith

Checks if the field value starts with the given string.

Example:

$GORM.Read("ExampleCollection", {"name__startswith": "Jo"})

istartswith

Case-insensitive check if the field value starts with the given string.

Example:

$GORM.Read("ExampleCollection", {"name__istartswith": "jo"})

endswith

Checks if the field value ends with the given string.

Example:

$GORM.Read("ExampleCollection", {"name__endswith": "n"})

iendswith

Case-insensitive check if the field value ends with the given string.

Example:

$GORM.Read("ExampleCollection", {"name__iendswith": "N"})

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.