我正在将google-cloud npm包与我的反应应用程序集成,我正在使用firebase.
我遇到的错误 -
警告在./~/google-cloud/~/hash-stream-validation/index.js找不到模块:错误:无法解析'/ home/linuxbox/React-Workspace/Kaptify/node_modules中的'fast-crc32c'/google-cloud/node_modules/hash-stream-validation'@ ./~/google-cloud/~/hash-stream-validation/index.js 5:8-30 @ ./~/google-cloud/~/@ google-cloud/storage/src/file.js @ ./~/google-cloud/~/@google-cloud/storage/src/index.js @ ./~/google-cloud/src/index.js @. /src/actions/UserStateStore.js @ ./app.js @ multi(webpack)-dev-server/client?http://127.0.0.1:3000 webpack/hot/dev-server ./app.js
警告在./~/google-cloud/~/google-auto-auth/index.js 53:13-58严重依赖:依赖的请求是表达式
警告在./~/google-cloud/~/grpc/src/node/src/grpc_extension.js 38:14-35严重依赖:依赖的请求是表达式
警告在./~/google-cloud/~/node-pre-gyp/lib/pre-binding.js 19:22-48严重依赖:依赖的请求是表达式
警告在./~/google-cloud/~/node-pre-gyp/lib/util/versioning.js 15:20-67严重依赖:依赖的请求是表达式
有人可以帮我解决这个问题吗?
假设我有一个名为 Vendor(id, name, lat, lon,created_at) 的模型。我有一个查询,其中我找到供应商与当前纬度和经度的距离。
查询是-
query = "*, ST_Distance(ST_SetSRID(ST_Point(#{lat}, #{lon}), 4326)::geography,ST_SetSRID(ST_Point(lat, lon), 4326)::geography) as distance"
Vendor.select(query)
Run Code Online (Sandbox Code Playgroud)
我的序列化器类为 -
class VendorSerializer < ActiveModel::Serializer
attributes :id,
:lat,
:lon,
:name,
:created_at
def attributes
hash = super
# I tried to override attributes and added distance but it doesn't add
hash[:distance] = object.distance if object.distance.present?
hash
end
end
Run Code Online (Sandbox Code Playgroud)
我想要一个序列化对象为 {id, lat, lon, name,created_at,distance}。因此,模型属性被附加,但我如何添加额外的字段/属性,即“距离”到序列化哈希?
ruby postgresql activerecord ruby-on-rails active-model-serializers