羽毛中where子句中函数的使用

时间:2019-05-22 11:39:15

标签: postgis feathersjs

问题是我需要在羽毛生成的SQL的where子句中包含一个函数

如果仅将where子句分配给该函数,则生成的SQL正确,但是我原因是缺少状态部分

options.where.status='Registreret'
options.where.fn=fn

SELECT 
   "id", "feature_name", "status", "priority", "label", "st_asgeojson" FROM "gis34_registration"."geojson_tasks" AS "geojson_tasks" 
WHERE 
   status = 'Registreret' AND 
   fn = ST_Intersects(geom, ST_transform(ST_MakeEnvelope(12.370044675467057, 55.73287419556607, 12.385791865781385, 55.7422305387, 4326), 25832))

这是我需要羽毛生成的SQL

SELECT 
   "id", "feature_name", "status", "priority", "label", "st_asgeojson" FROM "gis34_registration"."geojson_tasks" AS "geojson_tasks" 
WHERE 
   status = 'Registreret' AND 
   ST_Intersects(geom, ST_transform(ST_MakeEnvelope(12.370044675467057, 55.73287419556607, 12.385791865781385, 55.7422305387, 4326), 25832))

这是我需要羽毛生成的SQL

# Create graph
G = nx.Graph()
# Add id_emp nodes
G.add_nodes_from(df['id_emp'])
# Set 'name_emp' attribute for 'name_emp' column values
for node in G.nodes:
    G.nodes[node]['name_emp'] = df.loc[df['id_emp'] == node]['name_emp'].values[0]
# Add name_dep nodes
G.add_nodes_from(df['name_dep'])
# Create the new column with transformed 'roi' values
df['roi_new'] = df['roi'].apply(
    lambda x: 1 if x < 100 else 2 if 100 <= x < 1000 else 3
)
# Add weighted edges
G.add_weighted_edges_from(df[['id_emp', 'name_dep', 'roi_new']].values)

如何获得具有功能和属性的SQL生成的羽毛?

1 个答案:

答案 0 :(得分:1)

答案是使用预定义的$ per。下面的代码生成所需的SQL

options.where.status='Registreret'
options.where.$and=fn