当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript targaryen.database函数代码示例

本文整理汇总了TypeScript中targaryen.database函数的典型用法代码示例。如果您正苦于以下问题:TypeScript database函数的具体用法?TypeScript database怎么用?TypeScript database使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了database函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: it

  it('should be to delete comments as story or comment owner', () => {
    const data = {
      stories: {
        'abc': {
          owner: AUTH_STORY_OWNER.uid,
        }
      },
      comments: {
        'xyz': {
          story: 'abc',
          owner: AUTH_COMMENT_OWNER.uid,
        },
      },
    };
    const db = targaryen.database(rules, data);

    const asCommentOwner = db.as(AUTH_COMMENT_OWNER);
    const { allowed: allowedCommentOnwer } = asCommentOwner.write('comments/xyz', {});
    expect(allowedCommentOnwer).toBe(true);

    const asStoryOwner = db.as(AUTH_STORY_OWNER);
    const { allowed: allowedStoryOwner } = asStoryOwner.write('comments/xyz', {});
    expect(allowedStoryOwner).toBe(true);

    const asHacker = db.as(AUTH_HACKER);
    const { allowed: allowedHacker } = asHacker.write('comments/xyz', {});
    expect(allowedHacker).toBe(false);
  });
开发者ID:blmsl,项目名称:memories,代码行数:28,代码来源:comments.spec.ts

示例2: it

  it('should be able to edit as the owner', () => {
    const data = {
      users: {
        '123':  {
          displayName: '.',
        }
      },
      journeys: {
        'abc': {
          owner: '123',
          title: '🍭',
          updatedAt: 0,
        }
      }
    };
    const db = targaryen.database(rules, data);

    const asUser = db.as(AUTH_USER);
    const { allowed: allowedUser } = asUser.write('journeys/abc/title', '🍬');
    expect(allowedUser).toBe(true);

    const asHacker = db.as(AUTH_HACKER);
    const { allowed: allowedHacker } = asHacker.write('journeys/abc/title', 'HACKED');
    expect(allowedHacker).toBe(false);
  });
开发者ID:blmsl,项目名称:memories,代码行数:25,代码来源:journeys.spec.ts

示例3: it

  it('should be able to delete as the owner', () => {
    const data = {
      users: {
        '123': {
          displayName: '.'
        }
      },
      journeys: {
        'abc': {
          owner: '123',
        }
      },
      stories: {
        'xyz': {
          journey: 'abc',
          owner: '123',
          updatedAt: 0,
          title: '🍭'
        }
      }
    };
    const db = targaryen.database(rules, data);

    const asUser = db.as(AUTH_USER);
    const { allowed: allowedUser } = asUser.write('stories/xyz', null);
    expect(allowedUser).toBe(true);

    const asHacker = db.as(AUTH_HACKER);
    const { allowed: allowedHacker } = asHacker.write('stories/xyz', null);
    expect(allowedHacker).toBe(false);
  });
开发者ID:blmsl,项目名称:memories,代码行数:31,代码来源:stories.spec.ts

示例4: it

 it('should be able to read a list of users', () => {
   const data = {
     '123': {
       displayName: '🍭',
     }
   };
   const db = targaryen.database(rules, data);
   const { allowed } = db.read('users');
   expect(allowed).toBe(true);
 });
开发者ID:blmsl,项目名称:memories,代码行数:10,代码来源:users.spec.ts

示例5: it

  it('should not allow me to write if I\'m not signed in', () => {
    const data = {};
    const newUserPrivate = {
      email: null,
    };

    const db = targaryen.database(rules, data);
    const { allowed } = db.write('usersPrivate/null', newUserPrivate);
    expect(allowed).toBe(false);
  });
开发者ID:blmsl,项目名称:memories,代码行数:10,代码来源:users-private.spec.ts


注:本文中的targaryen.database函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。