Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Amplify datastore is not supporting multitenant #5222

Closed
rpostulart opened this issue Mar 28, 2020 · 11 comments
Closed

Amplify datastore is not supporting multitenant #5222

rpostulart opened this issue Mar 28, 2020 · 11 comments
Labels
DataStore Related to DataStore category duplicate If marked with duplicate, issue will be closed & original will be added for traceability
Milestone

Comments

@rpostulart
Copy link

The observe is listening to all model data, but it is not possible to only listen to specific data on the model and then apply specific queries and filters on that data.

@rpostulart rpostulart added the to-be-reproduced Used in order for Amplify to reproduce said issue label Mar 28, 2020
@rpostulart
Copy link
Author

So something like this:

const subscription = DataStore.observe(Post, 123).subscribe(msg => {
console.log(msg.model, msg.opType, msg.element);
});

So we only listen to Posts with id 123

@sammartinez sammartinez added the DataStore Related to DataStore category label Apr 2, 2020
@sammartinez sammartinez added this to the DataStore milestone Apr 2, 2020
@rpostulart
Copy link
Author

A better requirement description: tell datastore to only get data locally from a certain model with a certain ID

@undefobj
Copy link
Contributor

undefobj commented Apr 4, 2020

Could you give more specific information about the use case?

@rpostulart
Copy link
Author

I have this schema. The idea is to build an online quiz.
So an admin can create the quiz and send the gamecode to those who want to subscribe. Based on that gamecode they log in and see to quiz data.

But if you look in de localstorage you see all the quiz data and questions

`
type Quiz @model @auth(rules: [{ allow: public, provider: iam }]) {
id: ID!
title: String!
subscribers: [Subscribers] @connection(name: "QuizSubscribers")
seconds: Int!
currentQuestion: String
questionOrder: String
started: Boolean
view: Int
owner: String!
}

type Questions @model @auth(rules: [{ allow: public, provider: iam }]) {
id: ID!
image: String
youtube: String
question: String!
answerOne: String
answerOneCorrect: Boolean
answerTwo: String
answerTwoCorrect: Boolean
answerThree: String
answerThreeCorrect: Boolean
answerFour: String
answerFourCorrect: Boolean
quizID: String!
order: Int
public: Boolean
category: String
}
type QuestionsDB @model @auth(rules: [{ allow: public, provider: iam }]) {
id: ID!
image: String
youtube: String
question: String!
answerOne: String
answerOneCorrect: Boolean
answerTwo: String
answerTwoCorrect: Boolean
answerThree: String
answerThreeCorrect: Boolean
answerFour: String
answerFourCorrect: Boolean
relatedQuestion: String!
public: Boolean
category: String
language: String
}

type Subscribers @model @auth(rules: [{ allow: public, provider: iam }]) {
id: ID!
type: String!
score: Int!
quizID: String!
quiz: Quiz @connection(name: "QuizSubscribers")
name: String!
}

type Responses @model @auth(rules: [{ allow: public, provider: iam }]) {
id: ID!
quiz: String!
subscriber: String!
question: String!
}
type Languages
@model
@auth(rules: [{ allow: public, provider: iam }])
@key(name: "ByCode", fields: ["type", "code"], queryField: "getLangByCode") {
id: ID!
type: String!
code: String!
}

`

@undefobj
Copy link
Contributor

It is possible to observe one object like so:

const id = '69ddcb63-7e4a-4325-b84d-8592e6dac07b';

const subscription = DataStore.observe(Event, id).subscribe(msg => {
  console.log(msg.model, msg.opType, msg.element);
  onQuery();
});

This also came up here: https://github.com/aws-amplify/amplify-js/issues/5156
I'm adding a note internally to get this added to our docs. Additionally we have a feature we're working on related to the sync and filter functionality so that you can apply finer grained controls to the base query functionality. You can track that here: #5119

@rpostulart
Copy link
Author

Ok cool, so then only that data will be locally in the store and not the other data. Thx

@rpostulart
Copy link
Author

Is tracked here: #5119

@rpostulart
Copy link
Author

When I trigger this on a page load:

const id = "71192197-67f4-4e2d-9569-bbfd67085253"
const subscription = await DataStore.observe(Quiz, id).subscribe(msg => {
console.log(msg.model, msg.opType, msg.element)
})

It still loads all the models and data in the store

Screenshot 2020-04-10 at 07 54 31

@rpostulart rpostulart reopened this Apr 10, 2020
@undefobj
Copy link
Contributor

Observing a model is different than loading all the models. If you're looking to just load specific ones that's handled by the feature #5119

@sammartinez sammartinez added feature-request Request a new feature duplicate If marked with duplicate, issue will be closed & original will be added for traceability and removed to-be-reproduced Used in order for Amplify to reproduce said issue labels Apr 21, 2020
@sammartinez
Copy link
Contributor

Resolving this issue in favor of the open feature request that is open

@sammartinez sammartinez removed the feature-request Request a new feature label Apr 21, 2020
@github-actions
Copy link

This issue has been automatically locked since there hasn't been any recent activity after it was closed. Please open a new issue for related bugs.

Looking for a help forum? We recommend joining the Amplify Community Discord server *-help channels or Discussions for those types of questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
DataStore Related to DataStore category duplicate If marked with duplicate, issue will be closed & original will be added for traceability
Projects
None yet
Development

No branches or pull requests

3 participants