What db methods are available in Strapi v3 by default? - strapi

https://strapi.io/blog/using-database-transactions-to-write-queries-in-strapi?utm_source=dev.to&utm_medium=post&utm_id=blog
I read the documentation for v3, but it doesn't tell me what mongoose methods I have access to from the beginning, so I was wondering if there were any guide or documentation that told me how to access all the Mongoose methods for article for example?
I tried calling
strapi.services.article.findMany({
offset: 10,
limit: 10,
where: {
id: ctx.query.id
}
})
But I got: strapi.services.article.findMany is not a function
It works if I do:
strapi.services.article.find(ctx.query)

Strapi provides a query API to interact with the database layer. Whether you're using mysql, postgres or mongodb, the API will have the same interface by definition (see query API documentation).
find is the way to go to find many entries.
PS: Since the article you posted is about database transaction with Strapi, I advise you to read my article about the caveats to be aware of.

Related

CognitoUserManager.GetUsersInRoleAsync limits to 25 results

I am using the amazon.aspnetcore.identity.cognito package (https://www.nuget.org/packages/Amazon.AspNetCore.Identity.Cognito/3.0.0) from https://github.com/aws/aws-aspnet-cognito-identity-provider/.
This within a .net core project.
When calling the GetUsersInRoleAsync, I always seem to only get the first 25 users found for the given role. The role has 26 users, however it always limits to 25. Is there any reason for that, can this limit be ignored somehow?
await this.userManager.GetUsersInRoleAsync(userGroup.ToString());
I don't seem to find any related documentation about this.
Thanks in advance for your help and advice.
This doesn't use the UserManager, but you can also list users (and add filters) using the AWS SDK Cognito service client. There is also a paginator that can be used to get all the pages of data.

Is TypeGraphql with Apollo federation possible?

We are planning to migrate towards Apollo GraphQL, because of the Apollo federation feature which allows unifying multiple microservices behind a single GraphQL API. However we are using TypeGraphQL at the moment, and I believe them to be incompatible. The reason is that in Apollo federation I see you use special #key property
/* example from docs */
const typeDefs = gql`
type Query {
me: User
}
type User #key(fields: "id") {
id: ID!
username: String
}
`;
However, the schema for TypeGraphql is automatically generated from classes. Is there a way to still use both technologies, or they are mutually exclusive?
Typegraphql had added the support for it, check the examples here https://github.com/MichalLytek/type-graphql/tree/master/examples/apollo-federation
While it has support by using #Directive decorator, it's not quite easy to work with it on a large scale project. I'm currently implementing it on a complex project, and I'm not satisfied with the amount of boilerplate code needed to reference some type from another schema. There was some conversation about adding better support here:
https://github.com/MichalLytek/type-graphql/issues/351#issuecomment-549156066
I'm planning to add support if I will have time soon.
but it's still not implemented. I've created a repo where you can see minimal example (similar to one in type-graphql repo):
https://github.com/hrvojepavlinovic/apollo-federation-type-graphql

accessing table metadata from embedded Teiid server

I have embedded Teiid 12.3 in a Spring Boot application. I want to get into the metadata of my VDB in order to generate a diagram using graphviz-java. I assume that if I have a org.teiid.metadata.Table object, I can call getIncomingObjects() to get references to tables that table depends on. I just can't figure out how to navigate from the EmbeddedServer to the Table objects.
I looked into using the administration API available via EmbeddedServer.getAdmin(). From there, I can call getVDBs(), and from there I can navigate down to getModels(), but below that level there is only the model source via getSourceMetadataText(). I also tried subclassing EmbeddedServer to make getVDBRepository() public. I can call getVDBRepository()*.getModels(), but it returns the same Model objects only get me access to the source definition of the models, not the runtime metadata model.
I tried getVDBRepository().getSystemStore() and VDBRepository.getODBCStore(), but those MetadataStores are not for the VDB I have deployed.
I haven't found any examples by Google, Teeid JIRA, Teiid forum, or StackOverflow to help me.
Take look at [1] the getSchema method on Admin API, this method returns the string form of the metadata, however you can grab Schema object for object form. If you do not want that way, Teiid also exposes system catalog using many SYS tables, you can issue SQL queries to grab the metadata of schemas and schema items in a VDB. One for internal access, another is from external access.
BTW one of users created a dependency diagram tool that may be useful if you are trying to do something similar. See [2]. Let me know if you interested in pushing that further.
[1] https://github.com/teiid/teiid/blob/master/runtime/src/main/java/org/teiid/runtime/EmbeddedAdminImpl.java#L544-L557
[2] https://github.com/teiid/metadata-catalog-ui

New type for the deprecated grocery_or_supermarket type in google-places-API

Looks like google has deprecated a bunch of place types from their places API:
https://developers.google.com/places/web-service/supported_types
"The following types are deprecated, and will continue to be supported until February 16, 2017: establishment, finance, food, general_contractor, grocery_or_supermarket, health, place_of_worship."
I wasn't able to figure out what the new replacement types would be. "food" and "store" are too generic for a grocery related store.
Additionally, the documentation states that these types are deprecated only for the query API. The place-details results "may" still contain them.
A workaround I can implement is to fetch the places using a more generic type (e.g., store), and then filter on my end.. not ideal, but out of ideas. However, this also means that I'll rely on the more granular type (e.g., grocery_or_supermarket) to be mentioned in the response.
Can someone pls comment or share ideas on this issue? (did any of you have to deal with this? would be great if you can share your thoughts)
Thanks
Use Foursquare API for this data instead of Google, just get a Foursquare API key, check the API how to use details online and that should provide the data your need.

Spring social and facebook api 2.4

I'm using spring-social for facebook, <version>2.0.1.RELEASE</version> and it works fine if I use the 2.3 Facebook version API.
I create a new app with the version 2.4 and it doesn’t work correctly, since FB changed the API policies:
https://developers.facebook.com/blog/post/2015/07/08/graph-api-v2.4/
Fewer default fields for faster performance:
To help improve
performance on mobile network connections, we've reduced the number of
fields that the API returns by default. You should now use the
?fields=field1,field2 syntax to declare all the fields you want the
API to return.
For example the post contains only the id and message and not from-name and from-id, so the class Post contains only this two fields.
Now to read this value we need to add “?fields=from”.
The question is, is there a way to use spring social also with the version 2.4 ?
It seems that the problem persists. So, I am using as workaround the following method to bring back the fields I need:
Facebook facebook = new FacebookTemplate(accessToken);
Post post = facebook.fetchObject(postId, Post.class, "picture, message, source, story, caption, place, description, type, from, link, icon, shares, created_time, name");

Resources