小编Sel*_*bou的帖子

Firestore:删除文档和安全规则

描述

我在使用 firestore 处理删除时遇到问题。简而言之,我为这样的帖子创建了一个安全规则:

首先在规则中有一些功能:

服务 cloud.firestore {

function userRoles() {
    return ['admin', 'customer', 'reader'];
}

function userGenders() {
    return ['mal', 'female', 'other'];
}

function postVisibilities() {
    return ['public', 'private', 'protected'];
}

function postType() {
    return ['music', 'motion_design', 'graphic_art'];
}

function isPayment(paymentDoc) {
    return paymentDoc != null
        && paymentDoc.date is timestamp
        && paymentDoc.price is number
        && paymentDoc.price is number
        && paymentDoc.price > 0;
}

function isBill(billDoc) {
    return billDoc.sellerId is string
        && billDoc.buyerId is string
        && billDoc.postIds != null
        && …
Run Code Online (Sandbox Code Playgroud)

firebase firebase-security angularfire2 angular google-cloud-firestore

9
推荐指数
1
解决办法
1956
查看次数

GraphQL:更新数组

我在更新解析器中的数组时遇到了一些问题。我正在用typescript.

描述

我在datamodel.graphqlfor Prisma

type Service @model {
    id: ID! @unique
    title: String
    content: String
    createdAt: DateTime!
    updatedAt: DateTime!
    comments: [Comment!]! // Line to be seen here
    author: User!
    offer: Offer
    isPublished: Boolean! @default(value: "false")
    type: [ServiceType!]!
}

type Comment @model {
    id: ID! @unique
    author: User! @relation(name: "WRITER")
    service: Service!
    message: String!
}
Run Code Online (Sandbox Code Playgroud)

Prisma连接到GraphQl服务器,并在这其中,我所定义的突变:

commentService(id: String!, comment: String!): Service!
Run Code Online (Sandbox Code Playgroud)

所以是时候为给定的突变实现解析器了,我正在这样做:

async commentService(parent, {id, comment}, ctx: Context, info) {
    const userId …
Run Code Online (Sandbox Code Playgroud)

javascript typescript graphql prisma

5
推荐指数
1
解决办法
2469
查看次数