Closed tyler-dunkel closed 1 year ago
Is your collection file accessible to both client and server? Can you add debug: true and provide output on both the client and server console log?
Hi thanks for the quick answer, I changed the collection code to:
gameDetails = new Mongo.Collection('gamedetails');
gameDetails.friendlySlugs({
slugFrom: 'gameName',
slugField: 'slug',
debug: true
});
the code is in the lib/collections directory and my other friendly slug on another collection works perfectly from the same directory. I did not get anything on the client side console nor the server side terminal related to friendlySlugs. I am then using mongol to check out the docs from the gameDetails collection I sub to and do not see a slug field. The doc has a large array of objects called gameArt and then a bunch of string and int fields if that maybe could cause a problem.
I also attempted to change the name of the field from gameName to just 'name' and then attempted to call friendlySlugs with no arguments, a name string, and the above options object with 'name' in the slugFrom field. still nothing. And as I said this problem seems to be only on the gameDetails collection as the slugs work fine on my other collections. One, Achievements, has a doc structure of just a couple string and int fields and when friendlySlugs is called with a 'name' string argument, it produces a 'slug' field as well as a friendlySlugs field that contains the slug and index within an object.
Just to confirm, it is not creating a slug when you insert a new record into the gameDetails collection? If you are trying to add slugs to existing documents, you will need to update the documents somehow and the slug should be generated. You can follow the instructions here: https://github.com/todda00/meteor-friendly-slugs#creating-slugs-in-bulk-for-existing-documents
Can you paste the code you are using to insert a new document into the collection?
Yes. However, I am using upsert because i use the same functions to update and insert the docs. here is the code:
function updateXboxOneGameDetails(userId, game, gameId) {
var hexId = game.titleId.toString(16);
var url = 'game-details-hex/' + hexId;
var result = syncApiCaller(url);
if (result !== 'undefined') {
Meteor._debug(game.name);
var gameDetail = {
gameName: game.name,
gameDescription: result.data.Items[0].Description,
gameReducedDescription: result.data.Items[0].ReducedDescription,
gameReducedName: result.data.Items[0].ReducedName,
gameReleaseDate: result.data.Items[0].ReleaseDate,
gameId: gameId,
gameGenre: result.data.Items[0].Genres,
gameArt: result.data.Items[0].Images,
gamePublisherName: result.data.Items[0].PublisherName,
gameParentalRating: result.data.Items[0].ParentalRating,
gameAllTimePlayCount: result.data.Items[0].AllTimePlayCount,
gameSevenDaysPlayCount: result.data.Items[0].SevenDaysPlayCount,
gameThirtyDaysPlayCount: result.data.Items[0].ThirtyDaysPlayCount,
gameAllTimeRatingCount: result.data.Items[0].AllTimeRatingCount,
gameAllTimeAverageRating: result.data.Items[0].AllTimeAverageRating
};
gameDetails.upsert({ gameId: gameId }, { $set: gameDetail });
}
}
Ah, seems that the underlying package this is using for the hooks (https://github.com/matb33/meteor-collection-hooks/) doesn't support upsert yet. Seems that the package is close to having support for it, see: https://github.com/matb33/meteor-collection-hooks/issues/88. Once that package supports upsert, I will update this package to support it as well. I will add a note in the documentation about not supporting upserts yet. For now, you can split the upsert into insert / update code if you would like to use this package.
no problem I just moved it to a new collection that is using insert. Thanks for getting back to me.
it should be working now in the latest 1.0.0 version If you are still using this package please update it and check the behavior. If it's not working please ping me.
As it's an old issue I'm closing it.
here is the code in the collection file:
'''' gameDetails = new Mongo.Collection('gamedetails');
gameDetails.friendlySlugs('gameName');
'''''
and here is an example of the doc
'''' { _id: j32384032, gameId: 547203284, gameName: "Destiny", gameArt: [ {} ], gamePlayTime: 1349324023 }