Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[proposal] Support _add #153

Open
int8259 opened this issue Oct 14, 2024 · 4 comments
Open

[proposal] Support _add #153

int8259 opened this issue Oct 14, 2024 · 4 comments

Comments

@int8259
Copy link

int8259 commented Oct 14, 2024

There're many cases that user want to use aop to filter data, like soft delete. By adding support for '_add', it enables users to implement AOP queries more easily.

just like:

bllWhere := map[string]interface{}{
	"country":      "China",
	"role":         "driver",
	"age >":        45,
	"gmt_create <": builder.Raw("gmt_modified"),
	"_or": []map[string]interface{}{
		{
			"x1":    11,
			"x2 >=": 45,
		},
		{
			"x3":    "234",
			"x4 <>": "tx2",
		},
	},
}

aopWhere := map[string]interface{}{
	"_and": []map[string]interface{}{
	{
	      "is_del": 0,
        },        
	     bllWhere,
        },
}
@caibirdme
Copy link
Contributor

Sorry I don't understand what AOP exact mean in your case

@int8259
Copy link
Author

int8259 commented Oct 14, 2024

When writing business logic, it’s always done with bllWhere. When invoking, AOP should automatically inject conditions similar to {"is_del": 1} based on the context. Just like:
aopWhere
aop1
aop2
aop3

bllWhere
bll1
bll2
bll3

During execution, an algorithm needs to select an appropriate aopWhere, which is then combined with a specific bll to ultimately perform the query.

@caibirdme
Copy link
Contributor

Why not just BuildSelect(YourAOP(where))

@int8259
Copy link
Author

int8259 commented Oct 15, 2024

In IoT scenarios, when the MES system queries data, there are sometimes interactions with external systems to confirm AOP query requests. There can be situations like the following:
Items are divided by weight specifications.

aopWhere = {
"weight >": 10
}

bllWhere = {
"weight >": 20
}

Using YourAOP(bllWhere) means that developers need to parse SQL requests and perform boolean operations. By adding _add, the sql engine can parse (aopCond AND (bllCond)).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants