當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。