Trying to purge users from command line `node purge.js user`.

Solved General Discussion
  • I am writing a small program in python to remove bots from forum. Learning node.js and redis from about 2 days from now on but couldn't figure it out how to use build in module nodebb/src/posts/delete.js Posts.purge.

    So my question is, is it possible to remove user and all its content from command line?

    All my tries failed, and I am not sure how code suppose to look like.

  • You will have to init the database and then load the required module. Here is some sample code. As always make a backup of your database before running it.

    var nconf = require('nconf');
    
    nconf.file({
    	file: 'config.json'
    });
    
    var db = require('./src/database');
    
    db.init(function(err) {
    	if (err) {
    		console.log('NodeBB could not connect to your database. returned the following error: ' + err.message);
    		process.exit();
    	}
    
    	var userIdToDelete = '123';
    	var callerUid = 0;
    	var user = require('./src/user');
    	user.delete(callerUid, userIdToDelete, function (err) {
    		if (err) {
    			console.log(err.message);
    			return process.exit();
    		}
    		console.log('user id ' + userIdToDelete + ' deleted');
    		process.exit();
    	});
    });
    

    You would place this in a file in the root of your nodebb installation and run it with node filename.js. You can modify the userIdToDelete variable to delete a user by uid.

  • @baris Hm was doing similar approach, please check my another question with path.js error.


Suggested Topics


  • Increase line space?

    Solved General Discussion
    3
    0 Votes
    3 Posts
    461 Views

    That works, thanks @baris

  • Proper way to purge chats

    Solved NodeBB Development
    2
    0 Votes
    2 Posts
    2k Views

    I will answer myself on question. 😉

    You need to remove these documents (_key pattern) from objects collection:

    message:8 messages:uid:8:to:16 uid:1:chats

    * where numbers are identifiers

    Or if you don't want to do it manually, you could wait for future NodeBB Utils plugin:

    Screen Shot 2015-10-14 at 11.55.39 PM.png

  • Node.js v0.12 released.

    General Discussion
    2
    1 Votes
    2 Posts
    1k Views

    I think NodeBB works on io.js as well, although I ran into some socket.io issues... not sure if that was related or not, though.

    Nice to hear node 0.12 is finally released 😄

  • 0 Votes
    1 Posts
    1k Views

    Hello,
    I'm developing(trying :)) a user applications api system for mobile application. Users register application with ID and Secret. With UserAPI and Token System, posting posts, commenting, and chat.

    How can I make UserAPI system?

    sorry for my english 😞

  • Learning Node.js

    General Discussion
    13
    2 Votes
    13 Posts
    3k Views

    I'm trying to create some html with a variable that can be adjusted.

    <p>Bank Account:$</p> <p id="bankaccount">1000</p>

    Not sure how I would do this. I want the value of 1000 to appear beside of Bank Account:$. However since both are in separate p tags, I can't figure it out. I would also like to save the value to a javascript variable.

    EDIT* I figured to just create the entire string in Javascript. Easier to piece together.