问:
How to add multiple http request calls in foreach | Mule 3
I am using scatter-gather to call many endpoints with the same host and  different paths. How can I add the HTTP request connector inside For Each scope, that can loop into the different paths and add the payload to the same file?

My code is as below, I would like to loop over the HTTP request;

```<code><?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" xmlns:ftp="http://www.mulesoft.org/schema/mule/ee/ftp" xmlns:http="http://www.mulesoft.org/schema/mule/http"
    xmlns:file="http://www.mulesoft.org/schema/mule/file" xmlns:dw="http://www.mulesoft.org/schema/mule/ee/dw"
    xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
    xmlns:spring="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd
http://www.mulesoft.org/schema/mule/ee/dw http://www.mulesoft.org/schema/mule/ee/dw/current/dw.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/ee/ftp http://www.mulesoft.org/schema/mule/ee/ftp/current/mule-ftp-ee.xsd
http://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd">
    <http:request-config name="HTTP_Request_Configuration-testt" protocol="HTTPS" host="servicenow.com" port="443" doc:name="HTTP Request Configuration"/>
    <http:listener-config name="HTTP_Listener_Configuration1" host="0.0.0.0" port="8081" doc:name="HTTP Listener Configuration"/>
    <flow name="servicenow-call">
        <http:listener config-ref="HTTP_Listener_Configuration1" path="/test" doc:name="HTTP"/>
        <scatter-gather doc:name="Scatter-Gather">
            <http:request config-ref="HTTP_Request_Configuration-testt" path="/repo/cat1" method="GET" doc:name="HTTP Request 1"/>
            <http:request config-ref="HTTP_Request_Configuration-testt" path="/repo/cat2" method="GET" doc:name="HTTP Request 2"/>
            <http:request config-ref="HTTP_Request_Configuration-testt" path="/repo/cat3"" method="GET" doc:name="HTTP Request 4"/>

        </scatter-gather>
        <dw:transform-message doc:name="Set JSON">
            <dw:set-payload><![CDATA[%dw 1.0
%output application/json
---
payload]]></dw:set-payload>
        </dw:transform-message>
        <file:outbound-endpoint path="D:\Local\NewFile.json" outputPattern="first-#[function:datestamp:ddMMyyyy-HHmmss].json" responseTimeout="10000" doc:name="Write FIle"/>
        <exception-strategy ref="ImplementationChoice_Exception_Strategy" doc:name="Reference Exception Strategy"/>
    </flow>
</mule>
</code>```

答:
Check the below sample code how we can use foreach in your scenario. THis is in Mule4. I hope you can do it in Mule3 as well.

I am not sure why you want to use foreach. I would suggest use Scatter_Gather instead of foreach. Because foreach will work sequentially and Scatter_Gather works concurrently. Performance wise concurrent process is good.

```<code><?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core" xmlns:http="http://www.mulesoft.org/schema/mule/http"
    xmlns="http://www.mulesoft.org/schema/mule/core"
    xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd">
    <flow name="Testing_foreach_stackoverflowFlow" doc:id="95fe6a04-4aca-4106-a0b3-b53afb7be95a" >
        <scheduler doc:name="Scheduler" doc:id="e6a81b1c-43f9-486a-a451-b31bcadbe23f" >
            <scheduling-strategy >
                <fixed-frequency frequency="5" timeUnit="MINUTES"/>
            </scheduling-strategy>
        </scheduler>
        <set-variable value="#[%dw 2.0

output application/json

---

[]]" doc:name="Set Variable" doc:id="7b1bbba6-d63d-4f89-905b-8b9c7d6a7555" variableName="result"/>
        <set-payload value='#[["test1","test2"]]' doc:name="Set Payload" doc:id="1b7ff757-1a42-4291-b759-50632db842d3" />
        <foreach doc:name="For Each" doc:id="2010c075-b487-4977-8a34-0f58adb23a7d" >
            <http:request method="GET" doc:name="Request" doc:id="a0524fe5-2344-46c2-bb03-90660fb8fc04" url='#["http://localhost:8091/" ++ payload]'/>
            <ee:transform doc:name="Transform Message" doc:id="0aca9608-f7a1-4e1a-a246-11830b6f245e" >
                <ee:message >
                </ee:message>
                <ee:variables >
                    <ee:set-variable variableName="result" ><![CDATA[%dw 2.0
output application/json
---
vars.result + payload
                ]]></ee:set-variable>
                </ee:variables>
            </ee:transform>
            <logger level="INFO" doc:name="payload" doc:id="22bc3348-90f9-4290-bb53-ee4c19af1f18" message="#[payload]"/>
        </foreach>
        <logger level="INFO" doc:name="payload" doc:id="00e70062-6898-42d7-bc50-974f23a4cd93" message="#[payload]"/>
    </flow>
    <flow name="Testing_foreach_stackoverflowFlow1" doc:id="fc055a5c-09a0-4dce-99be-70e863ffb0ff" >
        <http:listener doc:name="Listener" doc:id="298d5fff-c712-4307-895a-7d4faac42eb1" config-ref="api-httpListenerConfig" path="/test1"/>
        <set-payload value='"grapes"' doc:name="Set Payload" doc:id="bfce761e-c63a-4a06-ab9b-f17360d9a7d2" />
    </flow>
    <flow name="Testing_foreach_stackoverflowFlow2" doc:id="12d67768-525e-46b0-91b4-ce9377b0b7d1" >
        <http:listener doc:name="Listener" doc:id="24fc80d9-0f93-4217-a1a2-3802b57ce3cb" config-ref="api-httpListenerConfig" path="/test2"/>
        <set-payload value='"banana"' doc:name="Set Payload" doc:id="01ad0e82-5f50-49a3-9804-10190953b1c0" />
    </flow>
</mule>

</code>```

Body:
I am using scatter-gather to call many endpoints with the same host and  different paths. How can I add the HTTP request connector inside For Each scope, that can loop into the different paths and add the payload to the same file?

My code is as below, I would like to loop over the HTTP request;

<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" xmlns:ftp="http://www.mulesoft.org/schema/mule/ee/ftp" xmlns:http="http://www.mulesoft.org/schema/mule/http"
    xmlns:file="http://www.mulesoft.org/schema/mule/file" xmlns:dw="http://www.mulesoft.org/schema/mule/ee/dw"
    xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
    xmlns:spring="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd
http://www.mulesoft.org/schema/mule/ee/dw http://www.mulesoft.org/schema/mule/ee/dw/current/dw.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/ee/ftp http://www.mulesoft.org/schema/mule/ee/ftp/current/mule-ftp-ee.xsd
http://www.mulesoft.org/schema/mule/ee/tracking http://www.mulesoft.org/schema/mule/ee/tracking/current/mule-tracking-ee.xsd">
    <http:request-config name="HTTP_Request_Configuration-testt" protocol="HTTPS" host="servicenow.com" port="443" doc:name="HTTP Request Configuration"/>
    <http:listener-config name="HTTP_Listener_Configuration1" host="0.0.0.0" port="8081" doc:name="HTTP Listener Configuration"/>
    <flow name="servicenow-call">
        <http:listener config-ref="HTTP_Listener_Configuration1" path="/test" doc:name="HTTP"/>
        <scatter-gather doc:name="Scatter-Gather">
            <http:request config-ref="HTTP_Request_Configuration-testt" path="/repo/cat1" method="GET" doc:name="HTTP Request 1"/>
            <http:request config-ref="HTTP_Request_Configuration-testt" path="/repo/cat2" method="GET" doc:name="HTTP Request 2"/>
            <http:request config-ref="HTTP_Request_Configuration-testt" path="/repo/cat3"" method="GET" doc:name="HTTP Request 4"/>

        </scatter-gather>
        <dw:transform-message doc:name="Set JSON">
            <dw:set-payload><![CDATA[%dw 1.0
%output application/json
---
payload]]></dw:set-payload>
        </dw:transform-message>
        <file:outbound-endpoint path="D:\Local\NewFile.json" outputPattern="first-#[function:datestamp:ddMMyyyy-HHmmss].json" responseTimeout="10000" doc:name="Write FIle"/>
        <exception-strategy ref="ImplementationChoice_Exception_Strategy" doc:name="Reference Exception Strategy"/>
    </flow>
</mule>

Body:
Check the below sample code how we can use foreach in your scenario. THis is in Mule4. I hope you can do it in Mule3 as well.

I am not sure why you want to use foreach. I would suggest use Scatter_Gather instead of foreach. Because foreach will work sequentially and Scatter_Gather works concurrently. Performance wise concurrent process is good.

<?xml version="1.0" encoding="UTF-8"?>

<mule xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core" xmlns:http="http://www.mulesoft.org/schema/mule/http"
    xmlns="http://www.mulesoft.org/schema/mule/core"
    xmlns:doc="http://www.mulesoft.org/schema/mule/documentation" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd">
    <flow name="Testing_foreach_stackoverflowFlow" doc:id="95fe6a04-4aca-4106-a0b3-b53afb7be95a" >
        <scheduler doc:name="Scheduler" doc:id="e6a81b1c-43f9-486a-a451-b31bcadbe23f" >
            <scheduling-strategy >
                <fixed-frequency frequency="5" timeUnit="MINUTES"/>
            </scheduling-strategy>
        </scheduler>
        <set-variable value="#[%dw 2.0
&#10;
&#10;output application/json
&#10;
&#10;---
&#10;
&#10;[]]" doc:name="Set Variable" doc:id="7b1bbba6-d63d-4f89-905b-8b9c7d6a7555" variableName="result"/>
        <set-payload value='#[["test1","test2"]]' doc:name="Set Payload" doc:id="1b7ff757-1a42-4291-b759-50632db842d3" />
        <foreach doc:name="For Each" doc:id="2010c075-b487-4977-8a34-0f58adb23a7d" >
            <http:request method="GET" doc:name="Request" doc:id="a0524fe5-2344-46c2-bb03-90660fb8fc04" url='#["http://localhost:8091/" ++ payload]'/>
            <ee:transform doc:name="Transform Message" doc:id="0aca9608-f7a1-4e1a-a246-11830b6f245e" >
                <ee:message >
                </ee:message>
                <ee:variables >
                    <ee:set-variable variableName="result" ><![CDATA[%dw 2.0
output application/json
---
vars.result + payload
                ]]></ee:set-variable>
                </ee:variables>
            </ee:transform>
            <logger level="INFO" doc:name="payload" doc:id="22bc3348-90f9-4290-bb53-ee4c19af1f18" message="#[payload]"/>
        </foreach>
        <logger level="INFO" doc:name="payload" doc:id="00e70062-6898-42d7-bc50-974f23a4cd93" message="#[payload]"/>
    </flow>
    <flow name="Testing_foreach_stackoverflowFlow1" doc:id="fc055a5c-09a0-4dce-99be-70e863ffb0ff" >
        <http:listener doc:name="Listener" doc:id="298d5fff-c712-4307-895a-7d4faac42eb1" config-ref="api-httpListenerConfig" path="/test1"/>
        <set-payload value='"grapes"' doc:name="Set Payload" doc:id="bfce761e-c63a-4a06-ab9b-f17360d9a7d2" />
    </flow>
    <flow name="Testing_foreach_stackoverflowFlow2" doc:id="12d67768-525e-46b0-91b4-ce9377b0b7d1" >
        <http:listener doc:name="Listener" doc:id="24fc80d9-0f93-4217-a1a2-3802b57ce3cb" config-ref="api-httpListenerConfig" path="/test2"/>
        <set-payload value='"banana"' doc:name="Set Payload" doc:id="01ad0e82-5f50-49a3-9804-10190953b1c0" />
    </flow>
</mule>


来源: stackexchange

问:
How to define a geometry field with Peewee Models
I have looked at examples online on how to create a geometry field with peewee and this is what I came up with so far:

```<code>class GeometryField(Field):
    db_field = 'geometry'

    def db_value(self, value):
        return fn.ST_GeomFromGeoJSON(value)

    def python_value(self, value):
        return fn.ST_AsGeoJSON(value)
</code>```

I have added this definition to a table like so:

```<code>class GeoJSON(BaseModel):

    geojson_id = UUIDField(primary_key=True, default=uuid.uuid4)
    geometry = GeometryField()
</code>```

Now, this thing wouldn't run and I don't understand what I missed to make it happen.
My aim is to manage insertions of geometric entities into the DB so that later I can make use of PostGIS to query based on locations.

The error I'm getting in the init phase:

peewee.ProgrammingError: syntax error at or near "NOT" LINE 1:
...geojson_id" UUID NOT NULL PRIMARY KEY, "geometry"  NOT NULL)

I init the table like so:

```<code>        GeoJSON.create_table("geojsons")
</code>```

What did I miss here? Did I need to do anything else before this geometryfield can be used?
Is there a secret geom field that Peewee supports out of the box that I don't know about?

答:
If you are coming back to this question later. The Peewee Syntax has changed since version 3.0. db_field has changed to field_type.

So to get it working:

Make sure you install the PostGIS extension on your postgres database.

CREATE EXTENSION postgis;

Create a custom field.

```<code>class GeometryField(Field):
    field_type = 'geometry'

    def db_value(self, value):
        return fn.ST_GeomFromGeoJSON(value)

    def python_value(self, value):
        return fn.ST_AsGeoJSON(value)
</code>```

Use the custom field in your model

```<code>class GeoJSON(BaseModel):
    geojson_id = UUIDField(primary_key=True, default=uuid.uuid4)
    geometry = GeometryField()
</code>```

Peewee Docs

ContentLicense: CC BY-SA 4.0

Body:
I have looked at examples online on how to create a geometry field with peewee and this is what I came up with so far:

class GeometryField(Field):
    db_field = 'geometry'

    def db_value(self, value):
        return fn.ST_GeomFromGeoJSON(value)

    def python_value(self, value):
        return fn.ST_AsGeoJSON(value)

I have added this definition to a table like so:

class GeoJSON(BaseModel):

    geojson_id = UUIDField(primary_key=True, default=uuid.uuid4)
    geometry = GeometryField()

Now, this thing wouldn't run and I don't understand what I missed to make it happen.
My aim is to manage insertions of geometric entities into the DB so that later I can make use of PostGIS to query based on locations.

The error I'm getting in the init phase:

peewee.ProgrammingError: syntax error at or near "NOT" LINE 1:
...geojson_id" UUID NOT NULL PRIMARY KEY, "geometry"  NOT NULL)

I init the table like so:

        GeoJSON.create_table("geojsons")

What did I miss here? Did I need to do anything else before this geometryfield can be used?
Is there a secret geom field that Peewee supports out of the box that I don't know about?

Body:
If you are coming back to this question later. The Peewee Syntax has changed since version 3.0. db_field has changed to field_type.

So to get it working:

Make sure you install the PostGIS extension on your postgres database.

CREATE EXTENSION postgis;

Create a custom field.

class GeometryField(Field):
    field_type = 'geometry'

    def db_value(self, value):
        return fn.ST_GeomFromGeoJSON(value)

    def python_value(self, value):
        return fn.ST_AsGeoJSON(value)

Use the custom field in your model

class GeoJSON(BaseModel):
    geojson_id = UUIDField(primary_key=True, default=uuid.uuid4)
    geometry = GeometryField()

Peewee Docs


问:
List all Kafka 0.10 topics using - -zookeeper flag without access to Zookeeper
I'm using kafka 0.10 without zookeeper. I want to get kafka topics list. This command is not working since we're not using zookeeper:
bin/kafka-topics.sh --list --zookeeper localhost:2181. How can I get the same output without zookeeper?

答:
Try this, I was having issues with the --zookeeper flag.

```<code>bin/kafka-topics.sh --list --bootstrap-server my-cluster-kafka-bootstrap:9092
</code>```

Body:
Try this, I was having issues with the --zookeeper flag.

bin/kafka-topics.sh --list --bootstrap-server my-cluster-kafka-bootstrap:9092


问:
Maven ignores linked repository and transitive dependency is unresolved
A repository linked in a dependency's pom should be used when handling its dependencies (according to the question Are Maven repository declarations transitive?). Unfortunately, it doesn't happen in my case.

My project has dependency org.apache.calcite:calcite-avatica:1.0.0-incubating. The pom of calcite-avatica requires the dependency eigenbase:eigenbase-properties:1.1.4 and adds conjar repository in <repositories>, as this is the only place where eigenbase-properties 1.1.4 can be found. When I try to build the project, I get an error:

Could not find artifact eigenbase:eigenbase-properties:pom:1.1.4 in central (https://repo.maven.apache.org/maven2)

Why is eigenbase-properties not pulled from conjar repository? Only repository from my project is queried, while the linked repository isn't.

My minimal pom for reference:

```<code><?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>org.example</groupId>
    <artifactId>unresolved-dependency</artifactId>
    <version>1.0-SNAPSHOT</version>

    <properties>
        <maven.compiler.source>8</maven.compiler.source>
        <maven.compiler.target>8</maven.compiler.target>
    </properties>

    <dependencies>
        <!-- https://mvnrepository.com/artifact/org.apache.calcite/calcite-avatica -->
        <dependency>
            <groupId>org.apache.calcite</groupId>
            <artifactId>calcite-avatica</artifactId>
            <version>1.0.0-incubating</version>
        </dependency>
    </dependencies>
</project>
</code>```

I'm using JDK 1.8 (as seen in the pom) and Maven 3.6.3 (to exclude the possibility that conjar is blocked as an external http repository, which is the default since 3.8.1; see How to disable maven blocking external HTTP repositores?).

It also isn't the case that I have some mirrors specified, as was the cause in the question: maven can't get dependency from transitive repository (sometimes).

答: There is no such a "transitive repository" resolution in the documentation of Maven: https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html</p>

Body:
A repository linked in a dependency's pom should be used when handling its dependencies (according to the question Are Maven repository declarations transitive?). Unfortunately, it doesn't happen in my case.

My project has dependency org.apache.calcite:calcite-avatica:1.0.0-incubating. The pom of calcite-avatica requires the dependency eigenbase:eigenbase-properties:1.1.4 and adds conjar repository in <repositories>, as this is the only place where eigenbase-properties 1.1.4 can be found. When I try to build the project, I get an error:

Could not find artifact eigenbase:eigenbase-properties:pom:1.1.4 in central (https://repo.maven.apache.org/maven2)

Why is eigenbase-properties not pulled from conjar repository? Only repository from my project is queried, while the linked repository isn't.

My minimal pom for reference:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>org.example</groupId>
    <artifactId>unresolved-dependency</artifactId>
    <version>1.0-SNAPSHOT</version>

    <properties>
        <maven.compiler.source>8</maven.compiler.source>
        <maven.compiler.target>8</maven.compiler.target>
    </properties>

    <dependencies>

        <dependency>
            <groupId>org.apache.calcite</groupId>
            <artifactId>calcite-avatica</artifactId>
            <version>1.0.0-incubating</version>
        </dependency>
    </dependencies>
</project>

I'm using JDK 1.8 (as seen in the pom) and Maven 3.6.3 (to exclude the possibility that conjar is blocked as an external http repository, which is the default since 3.8.1; see How to disable maven blocking external HTTP repositores?).

It also isn't the case that I have some mirrors specified, as was the cause in the question: maven can't get dependency from transitive repository (sometimes).


问:
Placing two divs next to each other on top of parent element
I am trying to place two divs next to each other but and on the top of the parent div but within the borders of the parent

I've tried with to set position:relative to the parent and position:relative to kids but didnt manage do make z-index work

The logic i go with is to set the outter border to the parent element and add background-color and border to the icon but z-index keeps on not working

Here is the what I'm trying to build:

.filters-select {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 8px;
  border: var(--backgroud-color) solid 2px;
  border-radius: 20px;
}

.filters-select i {
  /* dont know what goes here*/
}

.filters-select span {
  /* dont know what goes here*/
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" integrity="sha512-9usAa10IRO0HhonpyAIVpjrylPvoDwiPUiKdWk5t3PyolY1cOd4DSE0Ga+ri4AuTroPR5aQvXU9xC6qOPnzFeg==" crossorigin="anonymous" referrerpolicy="no-referrer" />

<div class="filters-select">
  <i class="fa-solid fa-money-bill-1"></i>
  <span>Low cost</span>
</div></code>```

答:
For the .filters-select i, you want to add your styling there to make it look like what you have in the picture. change the size, add some padding, give it a background and font color.

```<code>.filters-select i {
    font-size: 0.8rem;
    padding: 1.3rem;
    border-radius: 50%;
    background-color: #deebff;
    color: #0065fc;
}
</code>```

then you want .filters-select to have that border radius, but you may have to adjust the size of your .filters-select span so that it fits perfectly inside.

Body:
I am trying to place two divs next to each other but and on the top of the parent div but within the borders of the parent

I've tried with to set position:relative to the parent and position:relative to kids but didnt manage do make z-index work

The logic i go with is to set the outter border to the parent element and add background-color and border to the icon but z-index keeps on not working

Here is the what I'm trying to build:

.filters-select {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 8px;
  border: var(--backgroud-color) solid 2px;
  border-radius: 20px;
}

.filters-select i {
  /* dont know what goes here*/
}

.filters-select span {
  /* dont know what goes here*/
}

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css" integrity="sha512-9usAa10IRO0HhonpyAIVpjrylPvoDwiPUiKdWk5t3PyolY1cOd4DSE0Ga+ri4AuTroPR5aQvXU9xC6qOPnzFeg==" crossorigin="anonymous" referrerpolicy="no-referrer" />

  Low cost

Body:
For the .filters-select i, you want to add your styling there to make it look like what you have in the picture. change the size, add some padding, give it a background and font color.

.filters-select i {
    font-size: 0.8rem;
    padding: 1.3rem;
    border-radius: 50%;
    background-color: #deebff;
    color: #0065fc;
}

then you want .filters-select to have that border radius, but you may have to adjust the size of your .filters-select span so that it fits perfectly inside.


问:
make: Nothing to be done for `all'
I am going through an eg pgm to create a make file.

http://mrbook.org/tutorials/make/

My folder eg_make_creation contains the following files,

```<code>desktop:~/eg_make_creation$ ls
factorial.c  functions.h  hello  hello.c  main.c  Makefile
</code>```

Makefile

```<code># I am a comment, and I want to say that the variable CC will be
# the compiler to use.
CC=gcc
# Hwy!, I am comment no.2. I want to say that CFLAGS will be the
#options I'll pass to the compiler
CFLAGS=-c -Wall

all:hello

hello:main.o factorial.o hello.o
  $(CC) main.o factorial.o hello.o -o hello

main.o:main.c
  $(CC) $(CFLAGS) main.c

factorial.o:factorial.c
  $(CC) $(CFLAGS) factorial.c

hello.o:hello.c
  $(CC) $(CFLAGS) hello.c

clean:
  rm -rf *o hello
</code>```

error:

```<code>desktop:~/eg_make_creation$ make all
make: Nothing to be done for `all'.
</code>```

Please help me understand to compile this program.

答:
I was trying to install libuv on Ubuntu and i also got the error make: Nothing to be done for 'all'. As i see it, using make gives two ways to solve the problem, one for check and one for install. But i found a workaround
still use the sudo make check command - it helps to read all the error messages before deciding on further actions. Basically, i've introduced a regression that makes the update workaround inefficient. This error comes from make however, the workaround from install fixes this, just try to run sudo make install and see what happens.
The make command will be a local optimization at the expense of the overall result of check/install - c'est ma façon de parler.
I believe i have narrowed down the problem considerably: in the first case after check i have "FAIL: test/run-tests" and in the second after install i get "specify the full pathname of the library, or use the '-LLIBDIR'" This argument to check/install can be a list object to store information about completed installations.
So install reports partial success when nothing actually happened.

Try running the commands from root:

```<code>cd your_program
sh autogen.sh
./configure
make
make check
make install
</code>```

And then he writes that the installation was successful:

```<code>Libraries have been installed in:
/usr/local/lib
</code>```

ContentLicense: CC BY-SA 3.0

Title: make: Nothing to be done for `all'

Body:
I am going through an eg pgm to create a make file.

http://mrbook.org/tutorials/make/

My folder eg_make_creation contains the following files,

desktop:~/eg_make_creation$ ls
factorial.c  functions.h  hello  hello.c  main.c  Makefile

Makefile

# I am a comment, and I want to say that the variable CC will be
# the compiler to use.
CC=gcc
# Hwy!, I am comment no.2. I want to say that CFLAGS will be the
#options I'll pass to the compiler
CFLAGS=-c -Wall

all:hello

hello:main.o factorial.o hello.o
  $(CC) main.o factorial.o hello.o -o hello

main.o:main.c
  $(CC) $(CFLAGS) main.c

factorial.o:factorial.c
  $(CC) $(CFLAGS) factorial.c

hello.o:hello.c
  $(CC) $(CFLAGS) hello.c

clean:
  rm -rf *o hello

error:

desktop:~/eg_make_creation$ make all
make: Nothing to be done for `all'.

Please help me understand to compile this program.

Body:
I was trying to install libuv on Ubuntu and i also got the error make: Nothing to be done for 'all'. As i see it, using make gives two ways to solve the problem, one for check and one for install. But i found a workaround
still use the sudo make check command - it helps to read all the error messages before deciding on further actions. Basically, i've introduced a regression that makes the update workaround inefficient. This error comes from make however, the workaround from install fixes this, just try to run sudo make install and see what happens.
The make command will be a local optimization at the expense of the overall result of check/install - c'est ma façon de parler.
I believe i have narrowed down the problem considerably: in the first case after check i have "FAIL: test/run-tests" and in the second after install i get "specify the full pathname of the library, or use the '-LLIBDIR'" This argument to check/install can be a list object to store information about completed installations.
So install reports partial success when nothing actually happened.

Try running the commands from root:

cd your_program
sh autogen.sh
./configure
make
make check
make install

And then he writes that the installation was successful:

Libraries have been installed in:
/usr/local/lib


问:
Output variables of Lambda function as Cloudformation parameters in Codepipeline
I have a Codepipeline, and I am trying to pass the output variables of a Lambda function as a parameter of the next stage, a Cloudformation action, in this pipeline. Does anyone know if it can be done?</p>

答:
You can use the "Invoke Lambda" action within a CodePipeline, include a "Namespace" as part of that action, and then retrieve results from the Lambda's execution in later actions (a "CloudFormation Deploy" type, or other types as well).

Your "Invoke Lambda" action will look something like:

```<code>- Name: increment-version-number
  RunOrder: 1
  ActionTypeId:
    Category: Invoke
    Owner: AWS
    Version: 1
    Provider: Lambda
   Configuration:
     FunctionName: my-pipeline-executed-function
   Namespace: MyResults
</code>```

CodePipeline will invoke your Lambda, and will pass an input message that contains the data you need to communicate results back to CodePipeline when your Lambda finishes.

Your can see a javascript example of such a Lambda in the official AWS documentation at: https://docs.aws.amazon.com/codepipeline/latest/userguide/actions-invoke-lambda-function.html
You can implement your Lambda in any language.  The key pieces of the Lambda are:

parse the incoming message packet to find the identifiers you need to pass back to CodePipeline to signal your Lambda has completed.

execute the logic needed for your use case

invoke an api call back to CodePipeline to signal success (or failure) - that is either:
putJobSuccessResult (https://docs.aws.amazon.com/codepipeline/latest/APIReference/API_PutJobSuccessResult.html)
or putJobFailureResult (https://docs.aws.amazon.com/codepipeline/latest/APIReference/API_PutJobFailureResult.html)
If you have been successful, then you'll notice part of the api call payload is outputVariables.  This is where you can return the values you want to use later in the execution of your CodePipeline.

Here's a psudocode-ish Java example:

```<code>    public final void handleRequest(InputStream inputStream, OutputStream outputStream, Context context)
    {
        try {
            Object inputJson = jsonProvider.parse(inputStream, StandardCharsets.UTF_8.name());

            final String jobId = JsonPath.read(inputJson, "$.['CodePipeline.job'].id");
            logger.info("jobId={}", jobId);

            try {

                final GetJobDetailsResponse jobDetailsResponse = codePipelineClient.getJobDetails(GetJobDetailsRequest.builder()
                        .jobId(jobId)
                        .build());
                final JobDetails jobDetails = jobDetailsResponse.jobDetails();
                final String pipelineName = jobDetails.data().pipelineContext().pipelineName();
                logger.info("pipelineName={}", pipelineName);

                final Map<String, String> outputVariables = new HashMap<>();

                // do your interesting stuff here, populate the outputVariables map as required

                final GetPipelineStateResponse pipelineStateResponse = codePipelineClient.getPipelineState(GetPipelineStateRequest.builder()
                        .name(pipelineName)
                        .build());

                logger.info("marking job {} completed", jobId);
                codePipelineClient.putJobSuccessResult(
                        PutJobSuccessResultRequest.builder()
                                .jobId(jobId)
                                .outputVariables(outputVariables)
                                .build());

            } catch (Exception e) {
                logger.error("marking job {} failed", jobId);
                codePipelineClient.putJobFailureResult(PutJobFailureResultRequest.builder()
                        .jobId(jobId)
                        .failureDetails(FailureDetails.builder()
                                .type(FailureType.JOB_FAILED)
                                .message(e.getMessage())
                                .build())
                        .build());
                throw e;
            }
        }
        catch (Exception e) {
            logger.error(context.getAwsRequestId(), e);
        }
}
</code>```

You can finally get around to using the piece(s) of data from your Lambda later in your pipeline!

Use the "hash" notation to retrieve values from your "Namespace", e.g. #{MyResults.myVariableName}.

With Cloudformation actions you have the choice of using TemplateConfiguration and/or ParameterOverrides to pass Cloudformation parameters.  You'll need ParameterOverrides for Lambda extracted values (you can mix and match where values come from for parameters, i.e. have some from the TemplateConfiguration and others from ParameterOverrides), and it might look something like:

```<code> - Name: my-deployment
   ActionTypeId:
     Category: Deploy
     Owner: AWS
     Version: 1
     Provider: CloudFormation
   Configuration:
     ActionMode: CREATE_UPDATE
     StackName: my-stack-name
     TemplatePath: MyArtifacts::packaged-infrastructure.cfn.yaml
     TemplateConfiguration: MyArtifacts::pipeline/my-parameters.json
     ParameterOverrides: !Sub >
       {
         "MyParameterFromLambda": "#{MyResults.myVariableName}"
       }
</code>```

Body:
You can use the "Invoke Lambda" action within a CodePipeline, include a "Namespace" as part of that action, and then retrieve results from the Lambda's execution in later actions (a "CloudFormation Deploy" type, or other types as well).

Your "Invoke Lambda" action will look something like:

- Name: increment-version-number
  RunOrder: 1
  ActionTypeId:
    Category: Invoke
    Owner: AWS
    Version: 1
    Provider: Lambda
   Configuration:
     FunctionName: my-pipeline-executed-function
   Namespace: MyResults

CodePipeline will invoke your Lambda, and will pass an input message that contains the data you need to communicate results back to CodePipeline when your Lambda finishes.

Your can see a javascript example of such a Lambda in the official AWS documentation at: https://docs.aws.amazon.com/codepipeline/latest/userguide/actions-invoke-lambda-function.html
You can implement your Lambda in any language.  The key pieces of the Lambda are:

parse the incoming message packet to find the identifiers you need to pass back to CodePipeline to signal your Lambda has completed.

execute the logic needed for your use case

invoke an api call back to CodePipeline to signal success (or failure) - that is either:
putJobSuccessResult (https://docs.aws.amazon.com/codepipeline/latest/APIReference/API_PutJobSuccessResult.html)
or putJobFailureResult (https://docs.aws.amazon.com/codepipeline/latest/APIReference/API_PutJobFailureResult.html)
If you have been successful, then you'll notice part of the api call payload is outputVariables.  This is where you can return the values you want to use later in the execution of your CodePipeline.

Here's a psudocode-ish Java example:

    public final void handleRequest(InputStream inputStream, OutputStream outputStream, Context context)
    {
        try {
            Object inputJson = jsonProvider.parse(inputStream, StandardCharsets.UTF_8.name());

            final String jobId = JsonPath.read(inputJson, "$.['CodePipeline.job'].id");
            logger.info("jobId={}", jobId);

            try {

                final GetJobDetailsResponse jobDetailsResponse = codePipelineClient.getJobDetails(GetJobDetailsRequest.builder()
                        .jobId(jobId)
                        .build());
                final JobDetails jobDetails = jobDetailsResponse.jobDetails();
                final String pipelineName = jobDetails.data().pipelineContext().pipelineName();
                logger.info("pipelineName={}", pipelineName);

                final Map<String, String> outputVariables = new HashMap<>();

                // do your interesting stuff here, populate the outputVariables map as required

                final GetPipelineStateResponse pipelineStateResponse = codePipelineClient.getPipelineState(GetPipelineStateRequest.builder()
                        .name(pipelineName)
                        .build());

                logger.info("marking job {} completed", jobId);
                codePipelineClient.putJobSuccessResult(
                        PutJobSuccessResultRequest.builder()
                                .jobId(jobId)
                                .outputVariables(outputVariables)
                                .build());

            } catch (Exception e) {
                logger.error("marking job {} failed", jobId);
                codePipelineClient.putJobFailureResult(PutJobFailureResultRequest.builder()
                        .jobId(jobId)
                        .failureDetails(FailureDetails.builder()
                                .type(FailureType.JOB_FAILED)
                                .message(e.getMessage())
                                .build())
                        .build());
                throw e;
            }
        }
        catch (Exception e) {
            logger.error(context.getAwsRequestId(), e);
        }
}

You can finally get around to using the piece(s) of data from your Lambda later in your pipeline!

Use the "hash" notation to retrieve values from your "Namespace", e.g. #{MyResults.myVariableName}.

With Cloudformation actions you have the choice of using TemplateConfiguration and/or ParameterOverrides to pass Cloudformation parameters.  You'll need ParameterOverrides for Lambda extracted values (you can mix and match where values come from for parameters, i.e. have some from the TemplateConfiguration and others from ParameterOverrides), and it might look something like:

 - Name: my-deployment
   ActionTypeId:
     Category: Deploy
     Owner: AWS
     Version: 1
     Provider: CloudFormation
   Configuration:
     ActionMode: CREATE_UPDATE
     StackName: my-stack-name
     TemplatePath: MyArtifacts::packaged-infrastructure.cfn.yaml
     TemplateConfiguration: MyArtifacts::pipeline/my-parameters.json
     ParameterOverrides: !Sub >
       {
         "MyParameterFromLambda": "#{MyResults.myVariableName}"
       }


问:
Change the order of a Terraform destroy -Can't destroy a CloudFront OAI :the CF distribution hasn't switched to a new OAI before the orig is destroyed
In Terraform I have created a new project that creates a CloudFront Origin Access Identity. Let's call the the replacement OAI.

I have an existing Terraform project that has been run in the past that had created an original Origin Access Identity. This project also created the CloudFront distribution - Lets call this the original OAI and the original project.

I update the terraform in the original project to now have the CloudFront distribution use the replacement OAI (already created in the other replacement OAI project) and I commented out the code that created the original OAI project.

The issue I have now is that after I run a Terraform apply on the original project with the changes, the Terraform is trying to delete the original OAI before the cloudfront distribution has switched over to use the replacement OAI in the new code changes.

Here is the output of the Terraform apply with the destroy error

```<code>aws_cloudfront_origin_access_identity.main: Destroying... [id=E2ZPPB4JPINCIR]
aws_s3_bucket_policy.blog: Modifying... [id=99999blog.example.org]
aws_cloudfront_distribution.blog: Modifying... [id=E348CKFTF7SNVV]
aws_s3_bucket_policy.blog: Modifications complete after 1s [id=99999blog.example.org]
aws_cloudfront_distribution.blog: Still modifying... [id=E348CKFTF7SNVV, 10s elapsed]
aws_cloudfront_distribution.blog: Still modifying... [id=E348CKFTF7SNVV, 20s elapsed]
aws_cloudfront_distribution.blog: Still modifying... [id=E348CKFTF7SNVV, 3m10s elapsed]
aws_cloudfront_distribution.blog: Modifications complete after 3m13s [id=E348CKFTF7SNVV]

Error: CloudFrontOriginAccessIdentityInUse: The CloudFront origin access identity is still being used.
        status code: 409, request id: f6401cd3-baf4-4ba6-9027-6350521f80f2
</code>```

If I run the destroy again it will work and destroy it but I can not rely on manually running destroy again since this is running it a GitLab pipeline - The destroy has to work on its first run.

To sum it up - I need the aws_cloudfront_origin_access_identity.main: Destroying... to happen after the aws_cloudfront_distribution.blog: Modifications complete, not before.

How can I change this order? I played with depends on but can not get it to work. Is there something else I can try? Is there a sleep before destroy that I could add?

Here is the Terraform file with the code commented out that was used to create the original OAI. I now have it using a shell script with aws cli commnands to get the data needed to link up to the replacement OAI (get_oai_info.sh) . I commented out the "aws_cloudfront_origin_access_identity" resource so it would get destroyed.

```<code>## Original OAI creation ***THIS IS WHAT WAS JUST COMMENTED OUT
##   AND I WANT DESTROYED LAST AFTER THE NEW APPLY IS RUN*****:
# resource "aws_cloudfront_origin_access_identity" "main" {
#   comment = "Created for ${var.application} ${var.environment}"

#   provider = aws.cloudfront_account
# }

data "external" "oai_id" {
  program = ["bash", "${path.module}/get_oai_info.sh"]

  query = {
    id_lookup = "Id"
    environment  = var.environment
    account_nbr  = var.account_number
  }
}
</code>```

Here is the coudfront.tf file. I have the original OAI reference commented out and have it use the new/replacement OAI:

```<code>resource "aws_cloudfront_distribution" "blog" {
  origin {
    domain_name = "${aws_s3_bucket.blog.bucket_regional_domain_name}"
    origin_id   = "${local.s3_origin_id}"

    s3_origin_config {

      #1 - To test delete:
      #origin_access_identity = "${aws_cloudfront_origin_access_identity.main.cloudfront_access_identity_path}"

      #2 - ORIG working  - to test replacemment:
      origin_access_identity = "origin-access-identity/cloudfront/${data.external.oai-id.result["id"]}"
    }
  }
</code>```

答:
Have you looked at using terraform destroy command with the -target flag? This lets you target specific resources to destroy while avoiding messing with other stuff. The exception to that is that if you're destroying something that other resources depend on, they will also need to be deleted (Terraform will show you what it intends on deleting in the plan of course).

https://www.terraform.io/cli/commands/destroy

https://www.terraform.io/cli/commands/plan#target-address (Docs for a different command, but it's the same for them all. You can also do terraform plan -destroy -target=... to get a non-executing plan)

Body:
In Terraform I have created a new project that creates a CloudFront Origin Access Identity. Let's call the the replacement OAI.

I have an existing Terraform project that has been run in the past that had created an original Origin Access Identity. This project also created the CloudFront distribution - Lets call this the original OAI and the original project.

I update the terraform in the original project to now have the CloudFront distribution use the replacement OAI (already created in the other replacement OAI project) and I commented out the code that created the original OAI project.

The issue I have now is that after I run a Terraform apply on the original project with the changes, the Terraform is trying to delete the original OAI before the cloudfront distribution has switched over to use the replacement OAI in the new code changes.

Here is the output of the Terraform apply with the destroy error

aws_cloudfront_origin_access_identity.main: Destroying... [id=E2ZPPB4JPINCIR]
aws_s3_bucket_policy.blog: Modifying... [id=99999blog.example.org]
aws_cloudfront_distribution.blog: Modifying... [id=E348CKFTF7SNVV]
aws_s3_bucket_policy.blog: Modifications complete after 1s [id=99999blog.example.org]
aws_cloudfront_distribution.blog: Still modifying... [id=E348CKFTF7SNVV, 10s elapsed]
aws_cloudfront_distribution.blog: Still modifying... [id=E348CKFTF7SNVV, 20s elapsed]
aws_cloudfront_distribution.blog: Still modifying... [id=E348CKFTF7SNVV, 3m10s elapsed]
aws_cloudfront_distribution.blog: Modifications complete after 3m13s [id=E348CKFTF7SNVV]

Error: CloudFrontOriginAccessIdentityInUse: The CloudFront origin access identity is still being used.
        status code: 409, request id: f6401cd3-baf4-4ba6-9027-6350521f80f2

If I run the destroy again it will work and destroy it but I can not rely on manually running destroy again since this is running it a GitLab pipeline - The destroy has to work on its first run.

To sum it up - I need the aws_cloudfront_origin_access_identity.main: Destroying... to happen after the aws_cloudfront_distribution.blog: Modifications complete, not before.

How can I change this order? I played with depends on but can not get it to work. Is there something else I can try? Is there a sleep before destroy that I could add?

Here is the Terraform file with the code commented out that was used to create the original OAI. I now have it using a shell script with aws cli commnands to get the data needed to link up to the replacement OAI (get_oai_info.sh) . I commented out the "aws_cloudfront_origin_access_identity" resource so it would get destroyed.

## Original OAI creation ***THIS IS WHAT WAS JUST COMMENTED OUT
##   AND I WANT DESTROYED LAST AFTER THE NEW APPLY IS RUN*****:
# resource "aws_cloudfront_origin_access_identity" "main" {
#   comment = "Created for ${var.application} ${var.environment}"

#   provider = aws.cloudfront_account
# }

data "external" "oai_id" {
  program = ["bash", "${path.module}/get_oai_info.sh"]

  query = {
    id_lookup = "Id"
    environment  = var.environment
    account_nbr  = var.account_number
  }
}

Here is the coudfront.tf file. I have the original OAI reference commented out and have it use the new/replacement OAI:

resource "aws_cloudfront_distribution" "blog" {
  origin {
    domain_name = "${aws_s3_bucket.blog.bucket_regional_domain_name}"
    origin_id   = "${local.s3_origin_id}"

    s3_origin_config {

      #1 - To test delete:
      #origin_access_identity = "${aws_cloudfront_origin_access_identity.main.cloudfront_access_identity_path}"

      #2 - ORIG working  - to test replacemment:
      origin_access_identity = "origin-access-identity/cloudfront/${data.external.oai-id.result["id"]}"
    }
  }


问:
Hide sensible data from the user in the response NestJS/Mongoose
I started to play with nest in the last week and even if I found it super useful there is a few thing that I can't replicate from a classic Express/Mongoose app.
One of this things is giving sensitive data as a password in a return.

For example in an Express/Mongoose app, I will do this to clean what the User can see:

const { Schema, model } = require("mongoose");

const UserSchema = new Schema({
  name: {
    type: String,
    required: [true, "Name is required"],
  },
  email: {
    type: String,
    required: [true, "Email is required"],
    unique: true,
  },
  password: {
    type: String,
    required: [true, "Password is required"],
  },
  img: {
    type: String,
  },
  rol: {
    type: String,
    required: true,
    emun: ["ADMIN_ROL", "USER_ROL"],
  },
  state: {
    type: Boolean,
    default: true,
  },
  google: {
    type: Boolean,
    default: false,
  },
});

UserSchema.methods.toJSON = function () {
  const { __v, _id, password, ...user } = this.toObject();
  user.uid = _id;
  return user;
};

module.exports = model("Users", UserSchema);```
</div>
</div>
</p>
<p>Like you see, I implement the methods of the class to clean the <code>user</code> object and return a secure and clean response.</p>
<p>Meanwhile the similar way of creating an user schema witn <code>NestJS/Mongoose</code> is this:</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import { Document } from 'mongoose';

export type UserDocument = User & Document;

@Schema()
export class User {
  @Prop({
    required: [true, 'Name is required'],
  })
  name: string;
  @Prop({
    required: [true, 'Password is required'],
  })
  password: string;
  @Prop()
  img: string;
  @Prop({
    required: true,
    enum: ['ADMIN_ROL', 'USER_ROL'],
  })
  rol: string;
  @Prop({
    default: true,
  })
  state: boolean;
  @Prop({
    default: false,
  })
  google: boolean;
}

export const UserSchema = SchemaFactory.createForClass(User);</code>```

Very basic just fallowing the NestJS documentation.

Which is the best way to achieve the same result with Nest?

Also I will like the ask you any blog/youtuber that work with nest, it will be appreciated

答:
Nest.js provides Mapped Types from OpenAPI specification.

You can create DTOs with using PartialType, OmitType, PickType functions.

Body:
I started to play with nest in the last week and even if I found it super useful there is a few thing that I can't replicate from a classic Express/Mongoose app.
One of this things is giving sensitive data as a password in a return.

For example in an Express/Mongoose app, I will do this to clean what the User can see:

const { Schema, model } = require("mongoose");

const UserSchema = new Schema({
  name: {
    type: String,
    required: [true, "Name is required"],
  },
  email: {
    type: String,
    required: [true, "Email is required"],
    unique: true,
  },
  password: {
    type: String,
    required: [true, "Password is required"],
  },
  img: {
    type: String,
  },
  rol: {
    type: String,
    required: true,
    emun: ["ADMIN_ROL", "USER_ROL"],
  },
  state: {
    type: Boolean,
    default: true,
  },
  google: {
    type: Boolean,
    default: false,
  },
});

UserSchema.methods.toJSON = function () {
  const { __v, _id, password, ...user } = this.toObject();
  user.uid = _id;
  return user;
};

module.exports = model("Users", UserSchema);

Like you see, I implement the methods of the class to clean the user object and return a secure and clean response.

Meanwhile the similar way of creating an user schema witn NestJS/Mongoose is this:

import { Prop, Schema, SchemaFactory } from '@nestjs/mongoose';
import { Document } from 'mongoose';

export type UserDocument = User & Document;

@Schema()
export class User {
  @Prop({
    required: [true, 'Name is required'],
  })
  name: string;
  @Prop({
    required: [true, 'Password is required'],
  })
  password: string;
  @Prop()
  img: string;
  @Prop({
    required: true,
    enum: ['ADMIN_ROL', 'USER_ROL'],
  })
  rol: string;
  @Prop({
    default: true,
  })
  state: boolean;
  @Prop({
    default: false,
  })
  google: boolean;
}

export const UserSchema = SchemaFactory.createForClass(User);

Very basic just fallowing the NestJS documentation.

Which is the best way to achieve the same result with Nest?

Also I will like the ask you any blog/youtuber that work with nest, it will be appreciated


问:
How to outer-join two CSV files, using shell script?
I have two CSV files, like the following:

file1.csv

label,"Part-A"
"ABC mn","2.0"
"XYZ","3.0"
"PQR SN","6"
```
<p><strong>file2.csv</strong></p>
<pre class="lang-none prettyprint-override"><code>label,"Part-B"
"XYZ","4.0"
"LMN Wv","8"
"PQR SN","6"
"EFG","1.0"
</code>```

Desired Output.csv

label,"Part-A","Part-B"
"ABC mn","2.0",NA
"EFG",NA,"1.0"
"LMN Wv",NA,"8"
"PQR SN","6","6"
"XYZ","3.0","4.0"
```
<p>Currently with the below awk command i am able to combine the matching one's which have entries for label in both the files like PQR and XYZ but unable to append the ones that are not having label values present in both the files:</p>
```awk -F, 'NR==FNR{a[$1]=substr($0,length($1)+2);next} ($1 in a){print $0","a[$1]}' file1.csv file2.csv
```

答:
You mentioned join in the comment on my other answer, and I'd forgotten about this utility:

#!/bin/sh
rm -f *sorted.csv

# Join two files, normally inner-join only, but
# -  `-a 1 -a 2`:    include "unpaired lines" from file 1 and file 2
# -  `-1 1 -2 1`:    the first column from each is the "join column"
# -  `-o 0,1.2,2.2`: output the "join column" (0) and the second fields from files 1 and 2

join -a 1 -a 2 -1 1 -2 1 -o '0,1.2,2.2' -t, file1.csv file2.csv > joined.csv

# Add NA values
cat joined.csv | sed 's/,,/,NA,/' | sed 's/,$/,NA/' > unsorted.csv

# Sort, pull out header first
head -n 1 unsorted.csv > sorted.csv

# Then sort remainder
tail -n +2 unsorted.csv | sort -t, -k 1 >> sorted.csv
```
<p>And, here's <strong>sorted.csv</strong></p>
<pre class="lang-none prettyprint-override"><code>+--------+--------+--------+
| label  | Part-A | Part-B |
+--------+--------+--------+
| ABC mn | 2.0    | NA     |
+--------+--------+--------+
| EFG    | NA     | 1.0    |
+--------+--------+--------+
| LMN Wv | NA     | 8      |
+--------+--------+--------+
| PQR SN | 6      | 6      |
+--------+--------+--------+
| XYZ    | 3.0    | 4.0    |
+--------+--------+--------+
</code>```

Body:
I have two CSV files, like the following:

file1.csv

label,"Part-A"
"ABC mn","2.0"
"XYZ","3.0"
"PQR SN","6"

file2.csv

label,"Part-B"
"XYZ","4.0"
"LMN Wv","8"
"PQR SN","6"
"EFG","1.0"

Desired Output.csv

label,"Part-A","Part-B"
"ABC mn","2.0",NA
"EFG",NA,"1.0"
"LMN Wv",NA,"8"
"PQR SN","6","6"
"XYZ","3.0","4.0"

Currently with the below awk command i am able to combine the matching one's which have entries for label in both the files like PQR and XYZ but unable to append the ones that are not having label values present in both the files:

awk -F, 'NR==FNR{a[$1]=substr($0,length($1)+2);next} ($1 in a){print $0","a[$1]}' file1.csv file2.csv

Body:
You mentioned join in the comment on my other answer, and I'd forgotten about this utility:

#!/bin/sh
rm -f *sorted.csv

# Join two files, normally inner-join only, but
# -  `-a 1 -a 2`:    include "unpaired lines" from file 1 and file 2
# -  `-1 1 -2 1`:    the first column from each is the "join column"
# -  `-o 0,1.2,2.2`: output the "join column" (0) and the second fields from files 1 and 2

join -a 1 -a 2 -1 1 -2 1 -o '0,1.2,2.2' -t, file1.csv file2.csv > joined.csv

# Add NA values
cat joined.csv | sed 's/,,/,NA,/' | sed 's/,$/,NA/' > unsorted.csv

# Sort, pull out header first
head -n 1 unsorted.csv > sorted.csv

# Then sort remainder
tail -n +2 unsorted.csv | sort -t, -k 1 >> sorted.csv

And, here's sorted.csv

+--------+--------+--------+
| label  | Part-A | Part-B |
+--------+--------+--------+
| ABC mn | 2.0    | NA     |
+--------+--------+--------+
| EFG    | NA     | 1.0    |
+--------+--------+--------+
| LMN Wv | NA     | 8      |
+--------+--------+--------+
| PQR SN | 6      | 6      |
+--------+--------+--------+
| XYZ    | 3.0    | 4.0    |
+--------+--------+--------+


问:
Finding Minimum For every group in ArrayList in Java
I have a class as below.

```<code>public class Employee{
int EmployeeDepartmentId;
int EmplyoyeeId;
int Salary;
}
</code>```

I an creating an ArrayList as Below.

```<code>ArrayList<Employee> arrEmployee = new ArrayList<Employee>;
</code>```

Now, I want to find out List of employees from every department with minimum salary.

How can this be achieved. I tried using Collections.Min(), but that will give me the minimum salary from whole list. I want it to be grouped by department.

Any suggestions?

答:
Using the idea by Jim, something like this should work:</p>

```<code>Map<Integer, List<Employee>> hmap = new HashMap<Integer, List<Employee>>();
int i = 0;
int size = arrEmployee.size();
for(i = 0; i < size; i++)
{
    Employee emp = arrEmployee.get(i);
    List<Employee> list = hmap.get(emp.EmployeeDepartmentId);
    if (list == null)
    {
        list = new ArrayList<Employee>();
    }
    list.add(emp);
    hmap.put(emp.EmployeeDepartmentId, list);
}
</code>```

Body:
I have a class as below.

public class Employee{
int EmployeeDepartmentId;
int EmplyoyeeId;
int Salary;
}

I an creating an ArrayList as Below.

ArrayList<Employee> arrEmployee = new ArrayList<Employee>;

Now, I want to find out List of employees from every department with minimum salary.

How can this be achieved. I tried using Collections.Min(), but that will give me the minimum salary from whole list. I want it to be grouped by department.

Any suggestions?

Body:
Using the idea by Jim, something like this should work:

Map<Integer, List<Employee>> hmap = new HashMap<Integer, List<Employee>>();
int i = 0;
int size = arrEmployee.size();
for(i = 0; i < size; i++)
{
    Employee emp = arrEmployee.get(i);
    List<Employee> list = hmap.get(emp.EmployeeDepartmentId);
    if (list == null)
    {
        list = new ArrayList<Employee>();
    }
    list.add(emp);
    hmap.put(emp.EmployeeDepartmentId, list);
}


问:
How to scale the uploaded image in P5JS
I am trying to write a stamp tool function that can upload an image as a stamp. Unfortunately, I am unable to scale the image as a stamp size. For example. the image remains the original size but the stamp size is 50x50. Therefore, the stamp can only show the top left corner of the image.

I tried to use the size or resize function in P5js but it doesn't work.

I initialise a global variable called "stamp" and the size.

```<code>    stamp = loadImage('./stamps/star.png');
    this.size = 50;
</code>```

In the P5JS draw function

```<code>    image(stamp, mouseX, mouseY, this.size, this.size);
</code>```

In my handleFile function

```<code>var handleFile = function (file) {
    print(file);
    if (file.type === 'image') {
        var targetStamp = createDiv();
        targetStamp.class('stamps');
        newStamp = createImg(file.data, '', () => { newStamp.size(100, AUTO) });
        targetStamp.child(newStamp);
        stampSelector = select(".stampSelector");
        stampSelector.child(targetStamp);

        targetStamp.mouseClicked(function () {
            var items = selectAll(".stamps");
            for (var i = 0; i < items.length; i++) {
                items[i].style('border', '0')
            }
            targetStamp.style("border", "2px solid blue");
            stamp = newStamp;
        })
    } else {
        img = null;
    }
}
</code>```

The size is succeeded to change by CSS, but cannot use as a stamp. Anyone can help please.

答:
When you say "cannot use as a stamp" it is not clear what the problem is. With a simplified version of your code it generally seems to work. However, it would appear that there is a bug with how the image() function handles source  elements that have been resized (it crops the source to the specified size, instead of using the original image dimensions, even when you explicitly specify source dimensions). There is a workaround though: using a CSS transform to control the size of the  element.

let img;
let size = 50;

function setup() {
  createCanvas(400, 400);
  let input = createFileInput(handleFile);
  input.position(10, 10);
  noLoop();
  background(0);
}

function draw() {}

function mouseClicked() {
  if (img) {
    image(img, mouseX, mouseY, size, size);
  }
}

function handleFile(file) {
  if (file.type === "image") {
    img = createImg(file.data, "uploaded image", "anonymous", () => {
      // This resizes the  tag, but will not effect the size of the image when drawn.
      // img.size(100, AUTO);
      img.style('transform', `scale(${100 / img.width})`);
      img.style('transform-origin', 'top left');
    });
  } else {
    img = null;
  }
}```
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.4.0/p5.js"></script></code>```

Title: How to scale the uploaded image in P5JS

Body:
I am trying to write a stamp tool function that can upload an image as a stamp. Unfortunately, I am unable to scale the image as a stamp size. For example. the image remains the original size but the stamp size is 50x50. Therefore, the stamp can only show the top left corner of the image.

I tried to use the size or resize function in P5js but it doesn't work.

I initialise a global variable called "stamp" and the size.

    stamp = loadImage('./stamps/star.png');
    this.size = 50;

In the P5JS draw function

    image(stamp, mouseX, mouseY, this.size, this.size);

In my handleFile function

var handleFile = function (file) {
    print(file);
    if (file.type === 'image') {
        var targetStamp = createDiv();
        targetStamp.class('stamps');
        newStamp = createImg(file.data, '', () => { newStamp.size(100, AUTO) });
        targetStamp.child(newStamp);
        stampSelector = select(".stampSelector");
        stampSelector.child(targetStamp);

        targetStamp.mouseClicked(function () {
            var items = selectAll(".stamps");
            for (var i = 0; i < items.length; i++) {
                items[i].style('border', '0')
            }
            targetStamp.style("border", "2px solid blue");
            stamp = newStamp;
        })
    } else {
        img = null;
    }
}

The size is succeeded to change by CSS, but cannot use as a stamp. Anyone can help please.

Body:
When you say "cannot use as a stamp" it is not clear what the problem is. With a simplified version of your code it generally seems to work. However, it would appear that there is a bug with how the image() function handles source <img> elements that have been resized (it crops the source to the specified size, instead of using the original image dimensions, even when you explicitly specify source dimensions). There is a workaround though: using a CSS transform to control the size of the <img> element.

let img;
let size = 50;

function setup() {
  createCanvas(400, 400);
  let input = createFileInput(handleFile);
  input.position(10, 10);
  noLoop();
  background(0);
}

function draw() {}

function mouseClicked() {
  if (img) {
    image(img, mouseX, mouseY, size, size);
  }
}

function handleFile(file) {
  if (file.type === "image") {
    img = createImg(file.data, "uploaded image", "anonymous", () => {
      // This resizes the <img> tag, but will not effect the size of the image when drawn.
      // img.size(100, AUTO);
      img.style('transform', `scale(${100 / img.width})`);
      img.style('transform-origin', 'top left');
    });
  } else {
    img = null;
  }
}

<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.4.0/p5.js"></script>


问:
Unique identifier for all fix messages related to a sinqle request in quickfix
We need to get a unique identifier for all related fix messages in quickfixj.
scenario: if  B lies between A and C and forwards fix messages from A to C and vice versa, we need to get a unique Id for all related messages to cache them in B.

Is there a uniqueId for all fix messages as mentioned above? if yes, does getting that unique identifier same (eg: message.getString(int field)) for all message types, or getting it depends on message type?

答:
Do you mean a unique identifier per Order, for example? If yes, then that would be 11/ClOrdID for a NewOrderSingle (and some other message types). But you'll have other identifiers for other message types, e.g. quotes, market data snapshots, ...

There is no global unique identifier per se, so you would need to make one up. For example a concatenation of SenderCompID and MsgSeqNum and SendingTime should be unique. If you are sure that you will not reset the sequence number intra-day you could probably even leave out the SendingTime.


问:
Angular: reset the form back to it´s original value after closing and reopening the modal
I have this problem - I have an items section - on the item click, there is a modal window opened with the possibility to edit text of the item inside textarea. However, when I edit the text and cancel/close the modal and then reopen again, the text is in the previously modified state. My goal is to reset the text to the correct existing state - so any update of the text before closing of the modal is removed.

Can you suggest some solution / function / link?

```<code><form [formGroup]="editForm" (ngSubmit)="editItem()">
  <textarea rows="3" formControlName="text"></textarea>
  <button type="submit">Save</button>
  <button type="button" (click)="closeModal()">Close</button>
</form>
</code>```
```<code>export class EditItemComponent implements OnInit, OnChanges {
  @Input() item: Item;
  editForm: FormGroup;

  ngOnInit(): void {
    this.editForm = new FormGroup({
      text: new FormControl('', [Validators.required, Validators.minLength(3)]),
    });
  }

  ngOnChanges(): void {
    this.editForm.controls.text.setValue(this.item.text);
  }

  editItem():void {
  //edit item logic
  }

  closeModal(): void {
    //logic for closing modal
    //here I know I can simply set the editForm text
    //back to the original text but I want the general
    //solution which will handle other possible scenarios - clicking away
    //from modal closes the modal, pressing esc closes the modal ...
  }
}
</code>```

答:
I think the issue here is that when you edit the form when the modal is open, you're changing the value in the text field of the form. So if the modal is closed and opened again, the same current value in the text field is also present in the modal.

You could either place your entire form inside the modal itself so that the state is clean each time the modal is opened, or implement something similar to Angular Material's MatDialog.

Body:
I have this problem - I have an items section - on the item click, there is a modal window opened with the possibility to edit text of the item inside textarea. However, when I edit the text and cancel/close the modal and then reopen again, the text is in the previously modified state. My goal is to reset the text to the correct existing state - so any update of the text before closing of the modal is removed.

Can you suggest some solution / function / link?

<form [formGroup]="editForm" (ngSubmit)="editItem()">
  <textarea rows="3" formControlName="text"></textarea>
  <button type="submit">Save</button>
  <button type="button" (click)="closeModal()">Close</button>
</form>

export class EditItemComponent implements OnInit, OnChanges {
  @Input() item: Item;
  editForm: FormGroup;

  ngOnInit(): void {
    this.editForm = new FormGroup({
      text: new FormControl('', [Validators.required, Validators.minLength(3)]),
    });
  }

  ngOnChanges(): void {
    this.editForm.controls.text.setValue(this.item.text);
  }

  editItem():void {
  //edit item logic
  }

  closeModal(): void {
    //logic for closing modal
    //here I know I can simply set the editForm text
    //back to the original text but I want the general
    //solution which will handle other possible scenarios - clicking away
    //from modal closes the modal, pressing esc closes the modal ...
  }
}


问:
Hibernate: CascadeType on ManyToMany relation with extra column
So I got two entities, Student and Course. One Student can have many Course and one Course can have many Student. Normally, I would have Hibernate generate a jointable like this:

@ManyToMany
@JoinTable(
            name="studentCourseJoinTable",
            joinColumns= {
                    @JoinColumn(
                            name="studentId",
                            referencedColumnName="studentId"
                            ) },
            inverseJoinColumns= {
                    @JoinColumn(
                            name="courseId",
                            referencedColumnName="courseId")
                    }
            )
private List<Course> courses = new ArrayList<Course>();
```
<p>Problem is, that I need to store the <em>grade</em> of the student in this course. For the sake of simplicity, lets say it is just a normal integer value. Without Hibernate, I'd build a simple jointable with a extra column for the grade value, something like this:</p>
```+-----------+----------+-------+
| studentId | courseId | grade |
+-----------+----------+-------+
|         1 |        1 |     1 |
|         1 |        2 |     2 |
|         2 |        1 |     5 |
|         2 |        3 |     6 |
+-----------+----------+-------+
```
<p>So I followed this guide in the JPA Wikibook and set it up like this:</p>
<pre class="lang-java prettyprint-override"><code>@Entity
public class Student implements Serializable
{
    ...
    @OneToMany(mappedBy="student")
    private List<StudentCourse> courses = new ArrayList<StudentCourse>();
    ...
}
</code>```

@Entity
public class Course implements Serializable
{
    ...
    @OneToMany(mappedBy="course")
    private List<StudentCourse> courses = new ArrayList<StudentCourse>();
    ...
}
```
<pre class="lang-java prettyprint-override"><code>@Entity
@IdClass(StudentCourse.class)
public class StudentCourse implements Serializable
{
    @Id
    private int studentId;

    @Id
    private int courseId;

    private int grade;

    @ManyToOne
    @PrimaryKeyJoinColumn(name="studentId", referencedColumnName="studentId")
    private Student student;

    @ManyToOne
    @PrimaryKeyJoinColumn(name="courseId", referencedColumnName="courseId")
    private Course course;
    ...
}
</code>```

It is ugly, but it works how it should work.

Now, the problem: Cascading. It's no problem with the @ManyToMany relation in the first example (I got another relation within Student, but it doesn't matter for this problem).

What I want is that if I delete a Student, the corresponding rows in the StudentCourse table gets also dropped, and the other way around: If I delete a Course, the corresponding rows should also get dropped. But I don't get

where to put the cascade = CascadeType.XY

which type of the cascade

I tried to use cascade = CascadeType.MERGE on both the Student and the Course, but this just leads to this if I delete a Student:

```<code>2022-02-09T22:33:59.222+0100  ERROR  integrity constraint violation: foreign key no action; FKD0KC5NKFVH9A0DIFGUI129HFC table: STUDENTCOURSES
</code>```

答: Personally, always I create the foreign keys directly in the database with the CASCADE option. Not be if it is a valid option for you.</p>

Body:
So I got two entities, Student and Course. One Student can have many Course and one Course can have many Student. Normally, I would have Hibernate generate a jointable like this:

@ManyToMany
@JoinTable(
            name="studentCourseJoinTable",
            joinColumns= {
                    @JoinColumn(
                            name="studentId",
                            referencedColumnName="studentId"
                            ) },
            inverseJoinColumns= {
                    @JoinColumn(
                            name="courseId",
                            referencedColumnName="courseId")
                    }
            )
private List<Course> courses = new ArrayList<Course>();

Problem is, that I need to store the grade of the student in this course. For the sake of simplicity, lets say it is just a normal integer value. Without Hibernate, I'd build a simple jointable with a extra column for the grade value, something like this:

+-----------+----------+-------+
| studentId | courseId | grade |
+-----------+----------+-------+
|         1 |        1 |     1 |
|         1 |        2 |     2 |
|         2 |        1 |     5 |
|         2 |        3 |     6 |
+-----------+----------+-------+

So I followed this guide in the JPA Wikibook and set it up like this:

@Entity
public class Student implements Serializable
{
    ...
    @OneToMany(mappedBy="student")
    private List<StudentCourse> courses = new ArrayList<StudentCourse>();
    ...
}

@Entity
public class Course implements Serializable
{
    ...
    @OneToMany(mappedBy="course")
    private List<StudentCourse> courses = new ArrayList<StudentCourse>();
    ...
}

@Entity
@IdClass(StudentCourse.class)
public class StudentCourse implements Serializable
{
    @Id
    private int studentId;

    @Id
    private int courseId;

    private int grade;

    @ManyToOne
    @PrimaryKeyJoinColumn(name="studentId", referencedColumnName="studentId")
    private Student student;

    @ManyToOne
    @PrimaryKeyJoinColumn(name="courseId", referencedColumnName="courseId")
    private Course course;
    ...
}

It is ugly, but it works how it should work.

Now, the problem: Cascading. It's no problem with the @ManyToMany relation in the first example (I got another relation within Student, but it doesn't matter for this problem).

What I want is that if I delete a Student, the corresponding rows in the StudentCourse table gets also dropped, and the other way around: If I delete a Course, the corresponding rows should also get dropped. But I don't get

where to put the cascade = CascadeType.XY

which type of the cascade

I tried to use cascade = CascadeType.MERGE on both the Student and the Course, but this just leads to this if I delete a Student:

2022-02-09T22:33:59.222+0100  ERROR  integrity constraint violation: foreign key no action; FKD0KC5NKFVH9A0DIFGUI129HFC table: STUDENTCOURSES


问:
Does Common Lisp have any syntactic sugar for a while True, i.e. infinite, loop?
Common Lisp's LOOP macro has made it notorious for having everything and the kitchen sink when it comes to looping. Despite this, while loops are a bit difficult. Is the special case of while true, i.e. infinite loops, an exception? That is, does Common Lisp offer any syntactic sugar for infinite loops?

My attempts to find anything like this online have failed. This cookbook suggests making a circular list and then telling the LOOP macro to do something for each element in that infinite list. This clearly works, but it's not any sort of syntactic sugar. For comparison, the R language lets users write while(TRUE){...} as repeat{...}. This is the sort of syntactic sugar that I have in mind.

Note: As much as I love seeing Lisp macros, I'm not asking for anyone to implement repeat in Common Lisp. I want to know what is already in the language from the get go.

答:
The simple LOOP macro is an infinite loop.

```<code>(loop
  (print 1)
  (print 2))
</code>```

There's an implicit block named NIL around the body, so you can exit the loop using (return). This is the equivalent of break in other languages, although you can also supply a value to be used as the value of the loop expression.

Body:
The simple LOOP macro is an infinite loop.

(loop
  (print 1)
  (print 2))

There's an implicit block named NIL around the body, so you can exit the loop using (return). This is the equivalent of break in other languages, although you can also supply a value to be used as the value of the loop expression.


问:
How can i form the property in compose to return int(0) if condition is true and not return anything if condition is false?
How can i form this expression to return int value of 0 if true and don't return the property if false? warehouse event is an array and the property is inside a compose.

Expression:

if(contains(variables('WareHouseEvent'), 'OB_2910'), int(0), <not
return anything)

答:
An alternative to the first answer is to always add and then remove it after the fact.

This is an example you can copy into your own tenant for testing.

```<code>{
    "definition": {
        "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
        "actions": {
            "Compose_JSON_Object": {
                "inputs": {
                    "AnotherProperty": "Another Value",
                    "TestProperty": "@variables('Data')"
                },
                "runAfter": {
                    "Initialize_Integer": [
                        "Succeeded"
                    ]
                },
                "type": "Compose"
            },
            "Initialize_Integer": {
                "inputs": {
                    "variables": [
                        {
                            "name": "Data",
                            "type": "integer",
                            "value": 0
                        }
                    ]
                },
                "runAfter": {},
                "type": "InitializeVariable"
            },
            "New_JSON_Object": {
                "inputs": {
                    "variables": [
                        {
                            "name": "New Object",
                            "type": "object",
                            "value": "@if(equals(variables('Data'), 1), removeProperty(outputs('Compose_JSON_Object'), 'TestProperty'), outputs('Compose_JSON_Object'))"
                        }
                    ]
                },
                "runAfter": {
                    "Compose_JSON_Object": [
                        "Succeeded"
                    ]
                },
                "type": "InitializeVariable"
            }
        },
        "contentVersion": "1.0.0.0",
        "outputs": {},
        "parameters": {},
        "triggers": {
            "manual": {
                "conditions": [],
                "inputs": {},
                "kind": "Http",
                "type": "Request"
            }
        }
    },
    "parameters": {}
}
</code>```

I have an integer variable at the top which stores a value of either 1 or 0.

Then in my compose, I add that value to a property in the compose statement.

Then beneath that, I set a new variable with the (potentially) updated object using an expression to determine if the added property should be removed or not.

You'd just need to adjust the condition portion of the IF statement with your expression.

```<code>if(equals(variables('Data'), 1), removeProperty(outputs('Compose_JSON_Object'), 'TestProperty'), outputs('Compose_JSON_Object'))
</code>```

The property will be removed depending on the value of the Data variable.

Removed

Retained

Body:
An alternative to the first answer is to always add and then remove it after the fact.

This is an example you can copy into your own tenant for testing.

{
    "definition": {
        "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
        "actions": {
            "Compose_JSON_Object": {
                "inputs": {
                    "AnotherProperty": "Another Value",
                    "TestProperty": "@variables('Data')"
                },
                "runAfter": {
                    "Initialize_Integer": [
                        "Succeeded"
                    ]
                },
                "type": "Compose"
            },
            "Initialize_Integer": {
                "inputs": {
                    "variables": [
                        {
                            "name": "Data",
                            "type": "integer",
                            "value": 0
                        }
                    ]
                },
                "runAfter": {},
                "type": "InitializeVariable"
            },
            "New_JSON_Object": {
                "inputs": {
                    "variables": [
                        {
                            "name": "New Object",
                            "type": "object",
                            "value": "@if(equals(variables('Data'), 1), removeProperty(outputs('Compose_JSON_Object'), 'TestProperty'), outputs('Compose_JSON_Object'))"
                        }
                    ]
                },
                "runAfter": {
                    "Compose_JSON_Object": [
                        "Succeeded"
                    ]
                },
                "type": "InitializeVariable"
            }
        },
        "contentVersion": "1.0.0.0",
        "outputs": {},
        "parameters": {},
        "triggers": {
            "manual": {
                "conditions": [],
                "inputs": {},
                "kind": "Http",
                "type": "Request"
            }
        }
    },
    "parameters": {}
}

I have an integer variable at the top which stores a value of either 1 or 0.

Then in my compose, I add that value to a property in the compose statement.

Then beneath that, I set a new variable with the (potentially) updated object using an expression to determine if the added property should be removed or not.

You'd just need to adjust the condition portion of the IF statement with your expression.

if(equals(variables('Data'), 1), removeProperty(outputs('Compose_JSON_Object'), 'TestProperty'), outputs('Compose_JSON_Object'))

The property will be removed depending on the value of the Data variable.

Removed

Retained


问:
How to query against junction table directly
Let's use the TypeORM documentation's example of a many-to-many table:

```<code>@ManyToMany(type => Category)
@JoinTable({
    name: "question_categories", // table name for the junction table of this relation
    joinColumn: {
        name: "question",
        referencedColumnName: "id"
    },
    inverseJoinColumn: {
        name: "category",
        referencedColumnName: "id"
    }
})
categories: Category[];
</code>```

Let's say I want to query directly against this table to run something like select * from question_categories where category = 3;. How do I express this with TypeORM's query builder? The table doesn't correspond to an entity so I don't know how to refer to it with the query builder API. Do I need to use entityManager.query for this?

答: I ended up creating a new entity for the junction table and querying directly against it that way.</p>

Body:
Let's use the TypeORM documentation's example of a many-to-many table:

@ManyToMany(type => Category)
@JoinTable({
    name: "question_categories", // table name for the junction table of this relation
    joinColumn: {
        name: "question",
        referencedColumnName: "id"
    },
    inverseJoinColumn: {
        name: "category",
        referencedColumnName: "id"
    }
})
categories: Category[];

Let's say I want to query directly against this table to run something like select * from question_categories where category = 3;. How do I express this with TypeORM's query builder? The table doesn't correspond to an entity so I don't know how to refer to it with the query builder API. Do I need to use entityManager.query for this?